Syntax Highlighting on Blogspot

Syntax Highlighting Image

Using highlightjs


<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

Using Google Prettify

  • Also a nice alternative to highlightjs is google prettify 
  • Using it is as easy as adding the js file to your HTML Template
    <script src='https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?autoload=true&skin=sons-of-obsidian'></script>
  • And put you code into
     <pre class="prettyprint linenums lang-html">
      <code>
    YOUR CODE
      </code> 
     </pre>
    
  • You can choose other styles from the skin gallary and add your choice as parameter to the url &skin=sons-of-obsidia

Comments