Tuesday, May 6, 2014

Enable Google Code Prettify in Blogger


Go to "Template" => "Edit HTML"
Add below lines in <head></head>
  •  Static view template:

<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
  • Dynamic view template:

Refer to http://stackoverflow.com/questions/1852537/how-to-use-prettify-with-blogger-blogspot

<link href='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css' rel='stylesheet' type='text/css'/>
<script src='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js' type='text/javascript'/>
<script language='javascript' type='text/javascript'>
$(window.blogger.ui()).on('viewitem', function (event, post, element) {
    element.each(function () {
        // first argument is a callback function
        // second argument is a root element or document to check
        prettyPrint(null, this);
    });
});
</script>

Try below:
<pre class="prettyprint linenums">Input Code Here</pre> 

No comments:

Post a Comment

Popular Posts