Thursday, 4 July 2019

Code format and beautifier for code snippets in blogger.com

In almost all my blog posts I show code snippets or command line examples. To make code examples more readable they need to have code highlighting. One very nice and easy option that I liked for code highlighting is to use github gists. On my github I created one multi-file gist. To include only one file from multi-file gist use code sample below. Replace name before js with one provided by gist’s tag. Replace FileName with name of the file in the gist.

<script src="https://gist.github.com/[you_github_username]/[paste name from script tag].js?file=FileName">
</script>
The sample of commands I like to show in the sample box that is not prettifying the text. Use the sample code below to wrap the sample command between “pre” tags.

<pre class="code-font" style="background-color: #f5f6f7; border: 1px solid rgb(210, 211, 215); font-size: 13px; font-weight: normal; line-height: 2em; overflow: auto; padding: 1em; vertical-align: baseline; word-wrap: break-word;">
</pre>
Example of the sample command box.
C:\run_me.exe

No comments:

Post a Comment