This is essentially just based on Google prettify which can be found here.

Just stick the following code in the head of the page to load the javascript.

<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>

And then put the code you’d like to prettify in the following tags.

<pre class="prettyprint lang-html"></pre>

If using this for HTML you need to replace all < symbols with &lt; and all > with &gt;, the language should also be set to html in the pre class tag otherwise it doesn’t seem to format the HTML code correctly (at least snippetsĀ of html code). Other languages can be specified as well.

<pre class="prettyprint lang-html">

Leave a Reply

Your email address will not be published. Required fields are marked *