Using Syntax Highlighter

Syntax highlighter is used in courses where code is common. It is a javascript library that colors code according to the type of code it is. It works with Java, SQL, Python, etc.

To use Syntax highlighter, have your designer enable the module in your course, and then use the following html source code where you want to use it:

<pre class="brush: <inserttype>">
     Code here
</pre>

Where <inserttype> is, you would put the type of code: xml, html, python, jscript, etc. Here is a list of all the types of code you can use with this module.

If you want to highlight a line of code, simply add highlight: X after the brush statement, where X is the line number of the code you wish to highlight:

<pre class="brush: <inserttype>; highlight: [X]">
     Code here
</pre>

To eliminate line numbers, simply add gutter: false to the code, like this:

<pre class="brush: <inserttype>; gutter: false;">
     Code here
</pre>

 

To make sure that code cannot be copied from the View mode and pasted elsewhere, insert the following div tag around the whole page in question:

<div class="nocopy">
Page content
</div>

 

For more, visit this Syntax Highlighter page.

Enjoy!