SyntaxHighlighter is a WordPress plugin which allows you to easily post syntax-highlighted code to your site without losing it’s formatting or making any manual changes. There are some attributes and language syntax I need to remember whenever I want create a new tutorial but it’s not really easy for me to remember all of them.
So, I post all Shortcode Parameters and supported language syntax for a quick reference.
Shortcode Parameters
lang
orlanguage
— The language syntax to highlight with. You can alternately just use that as the tag.autolinks
— Toggle automatic URL linking.classname
— Add an additional CSS class to the code box.collapse
— Toggle collapsing the code box by default, requiring a click to expand it. Good for large code posts.firstline
— An interger specifying what number the first line should be (for the line numbering).gutter
— Toggle the left-side line numbering.highlight
— A comma-sperated list of line numbers to highlight. You can also specify a range. Example:2,5-10,12
htmlscript
— Toggle highlighting any extra HTML/XML. Good for when you’re mixing HTML/XML with another language, such as having PHP inside an HTML web page. The above preview has it enabled for example. This only works with certain languages.light
— Toggle light mode which disables the gutter and toolbar all at once.padlinenumbers
— Controls line number padding. Valid values arefalse
(no padding),true
(automatic padding), or an integer (forced padding).title
(v3 only) — Sets some text to show up before the code. Very useful when combined with thecollapse
parameter.toolbar
— Toggle the toolbar (buttons in v2, the about question mark in v3)wraplines
(v2 only) — Toggle line wrapping.
Some example shortcodes:
[php]your code here[/php]
[css autolinks="false" classname="myclass" collapse="false" firstline="1" gutter="true" highlight="1-3,6,9" htmlscript="false" light="false" padlinenumbers="false" smarttabs="true" tabsize="4" toolbar="true" title="example-filename.php"]your code here[/css]
[code lang="js"]your code here[/code]
[sourcecode language="plain"]your code here[/sourcecode]
Supported language syntax:
Brush name | Brush aliases |
---|---|
ActionScript3 | as3, actionscript3 |
Bash/shell | bash, shell |
ColdFusion | cf, coldfusion |
C# | c-sharp, csharp |
C++ | cpp, c |
CSS | css |
Delphi | delphi, pas, pascal |
Diff | diff, patch |
Erlang | erl, erlang |
Groovy | groovy |
JavaScript | js, jscript, javascript |
Java | java |
JavaFX | jfx, javafx |
Perl | perl, pl |
PHP | php |
Plain Text | plain, text |
PowerShell | ps, powershell |
Python | py, python |
Ruby | rails, ror, ruby |
Scala | scala |
SQL | sql |
Visual Basic | vb, vbnet |
XML | xml, xhtml, xslt, html, xhtml |