Code syntax highlighting
Note: You are currently viewing documentation for Moodle 3.2. Up-to-date documentation for the latest stable version of Moodle is probably available here: Code syntax highlighting.
You can color or highlight code snippets within Moodle resources, forum posts etc. To do so you must install the GeSHi (Generic Syntax Highlighter) Filter. This makes the power of GeSHi available in Moodle through the use of a pair of special tags.
You can download the GeSHi filter from here:
To install, unzip that archive into your filter/ directory and then enable it in the admin filter configuration screen.
Instructions for use
Enclose your code in spans under the source of html editor like so:
<span syntax="code">your code goes here</span>
<span syntax="code" linenumbers="yes">your code with line numbers</span>
and many others. See the GeSHi homepage for full details.
See the examples above. This filter is still under development so things may change.
The GeSHi homepage also has an interactive demo.
The last development for this filter appears to have been in 2008. Bug reports are welcome, please post them in the github issues system.