Search This Blog

Use google code prettify in blogger

  1. Login to blogger, "Template" -> "Edit HTML" -> "Proceed
  2. Copy the following code, and paste them right before </head>  in the template html:
    <link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
    <script type="text/javascript" language="javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/lang-css.js"></script>
    
  3. Replace <body> with <body onload="prettyPrint()">
  4. Now you can format your code use prettify, for example:
    <code class="prettyprint lang-js">
    <!-- your code here-->
    </code>
    

    or
    <pre class="prettyprint lang-js">
    <!-- your code here-->
    </pre>
    

SEE ALSO:

1 comment: