QUB Blogs

The BlogScape for QUB Staff & Students

Syntax Highlighting Code

We have added the Prettify GC Syntax Highlighter plugin which can highlight syntax and number lines of program code. You should Activate the plugin in your dashboard and then use as follows:


<pre class=”prettyprint”> // Put your code here. </pre>

Making Code HTML Safe

The plugin automatically makes highlighted code html-safe:

<pre class=”prettyprint”> Anything that goes here will be quoted to appear on the page as-is. For example: <head></head><body></body> </pre>

To avoid quoting your code, add dontquote as the first class:

<pre class=”dontquote prettyprint”> Remember to quote manually. For example: &lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt; </pre>

Line numbering

Line numbdering can be enabled as follows:

<pre class=”prettyprint linenums”> // Put your code here. </pre>

If you want to start with a line number 42, you can do the following:

<pre> // Put your code here. </pre>

Specifying Language

Most of the time the highlighter will do a good job guessing how to highlight the code. However, to achieve the best result, you should specify the language:

<pre class=”prettyprint lang-YOURLANG”> // Put your code here. </pre>

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>