To prepare for a series of posts here on server configuration tricks, I’ve installed one of the WordPress SyntaxHighlighter plugins to my blog. This is a good choice as it exposes the most options from the SyntaxHighlighter JS library.
Simply create a preformatted paragraph and enter the text to be highlighted. Top and tail this with [brush]
tags like so:
1
The value of the brush in the class is the SyntaxHighlighter Brush alias. This can be followed by various rendering options:
1
Below are the parameters you can pass and what they do. For the booleans (i.e. on/off), pass true
/1
or false
/0
.
lang
orlanguage
— The language syntax to highlight with.autolinks
— Toggle automatic URL linking.classname
— Add an additional CSS class to the code box.collapse
— Toggle collapsing the code box by defaultfirstline
— What number the first line should be.gutter
— Toggle the left-side line numbering.highlight
— Line numbers to highlight such as:2,5-10,12
htmlscript
— Toggle highlighting any extra HTML/XML.light
— Toggle light mode which disables the gutter and toolbar all at once.padlinenumbers
— Controls line number padding (false
,true
, or an integer).title
(v3 only) — Sets some text to show up before the code.toolbar
— Toggle the toolbar (buttons in v2, the about question mark in v3)wraplines
(v2 only) — Toggle line wrapping.
To display [tags]
as I have done above without having them interpreted by the plugin, make use of the fact that you can use both the [brush][/brush]
form (as above) and a more verbose alternative:
1