SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript. Once installed, it adds markup of the form:
(:code PARAMETERS:)[@ | or | (:code PARAMETERS:) |
Example HTML code with embedded PHP script:
CodeBlockMarkup($pagename
, PSS($m[1]), PSS($m[3]))
If JavaScript is disabled it will look like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <title>SyntaxHighlighter Demo</title> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <body> <div style="font-weight: bold"><?= str_replace("\n", "<br/>", $var) ?></div> <? /*********************************** ** Multiline block comments **********************************/ $stringWithUrl = "http://alexgorbatchev.com"; $stringWithUrl = 'http://alexgorbatchev.com'; ob_start("parseOutputBuffer"); // Start Code Buffering session_start(); ?> </body> </html>
Parameter | Default Value | Description |
---|---|---|
auto_links | true | Allows you to turn detection of links in the highlighted element on and off. If the option is turned off, URLs won't be clickable. |
collapse | false | Allows you to force highlighted elements on the page to be collapsed by default. |
first_line | 1 | Allows you to change the first (starting) line number. |
gutter | true | Allows you to turn gutter with line numbers on and off. |
highlight | null | Allows you to highlight one or more lines to focus user's attention. When specifying as a parameter, you have to pass an array looking value, like [1, 2, 3] or just an number for a single line. |
html_script | false | Allows you to highlight a mixture of HTML/XML code and a script which is very common in web development. Setting this value to true requires that the brush you are using supports this feature. |
light | false | Allows you to disable toolbar and gutter with a single property. |
ruler | false | Allows you to show column ruler on top of highlighted elements. |
smart_tabs | true | Allows you to turn smart tabs feature on and off. |
tab_size | 4 | Allows you to adjust tab size. |
toolbar | true | Toggles toolbar on/off. |
lang | plain | Selects the language. |
wrap_lines | true | Allows you to turn line wrapping feature on and off. |
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, xslt, html, xhtml |