{code to highlight}
* "''lang''" (if present) specifies the given code's (programming-) language;
* "''123''" (if present) specifies the first number to use when numbering the given code's lines;
* the first "''%%|%%''" (if present) delimits the first argument(s) from the remaining ones which are used to produce a //header// or //footer// above/below the highlighted code;
* a "''h''" (for //"header"//)((or "''t''" for //"top"//)) following //immediately// the pipe character causes the remaining "''text''" to get placed //above// the code, a "''f''" (for //"footer"//)((or "''b''" for //"bottom"//)) places the "''text''" below the code (note that this flag is //optional//; if omitted it defaults to "''f''");
* the "''text''" is used as-is with the additional benefit of getting wrapped by an anchor tag which allows for addressing the code from other pages.
* the second "''%%|%%''" (if present) delimits the header/footer text;
* a "''s''"((for //"show"//, the default)) or "''h''"((for //"hide"//)) character (if present) controls the code block's initial folding state; for more details see the [[#folding_state|Behaviour]] section below.
* the "''{code to highlight}''" is either the plain text to process or a pointer to an [[#external_files|external source]].
===== Examples =====
Please note that you will //not// see any highlighting //here//:
This section just shows some use cases without actually triggering the activation of the plugin -- even if it was installed ...
some text
and more
This just renders the given preformatted text without any special highlighting.
However,
some text
and more
will add line numbers in front of each line starting (in this case) with ''1'' (one).
var de = function() {
return (typeof(window.de) == 'object') ? window.de : {};
}();
This markup will turn on both the JavaScript syntax highlighting and the line numbering starting in this case with number ''12'' and place the text "''Listing 2''" below the code block -- producing HTML like:
12: var de = function() {
13: return (typeof(window.de) == 'object') ? window.de : {};
14: }();
If you'd rather the text //above// the code you'd just insert a "''h''" right after the pipe character i.e. "''%%%%''".
Of course, instead of ''javascript'' you may use any other highlighting mode supported by //GeSHi// like "''html''" for example or "''php''".
In case a language is given which is //not// supported by //GeSHi// there won't be any syntax highlighting, of course, but the line numbers (if requested) and header/footer lines (if requested) will appear nevertheless.
As mentioned above besides the line numbering feature this plugin provides an improved highlighting mode for "''diff''" files (aka "''patches''").
For "''diff''" the second argument can be either __''u''__ (for "//unified//"), __''c''__ (for "//context//"), __''n''__ (or __''r''__ for //RCS//) or __''s''__ (for "//simple//") format((Meaning, that line numbering is //not// available for "''diff''". It wouldn't make any sense anyway. Just think about it.)).
Although appreciated this argument is optional as well.
Omitting it will cause the plugin to perform some additional tests to figure out the "''diff''" format actually used.
A little sample:
--- syntax_plugin_code.php.orig 2007-02-23 11:33:35.000000000 +0100
+++ syntax_plugin_code.php 2007-02-23 11:53:17.000000000 +0100
@@ -595,14 +595,14 @@
$n = (int)$hits[5];
} // if
if (isset($hits[7]) && ($hits[7])) {
- $hits[6] = (isset($hits[6])) ? strtolower($hits[6]) . 'f' : 'f';
+ $hits[6] = (isset($hits[6])) ? strtolower($hits[6]) . 'h' : 'h';
switch ($hits[6]{0}) {
- case 'h':
- case 't':
- $ht = trim($hits[7]);
+ case 'b':
+ case 'f':
+ $ft = trim($hits[7]);
break;
default:
- $ft = trim($hits[7]);
+ $ht = trim($hits[7]);
break;
} // switch
if (isset($hits[8])) {
To summarize:
* Without the new arguments nothing changes from what you're used to know (and get) -- but see the [[#Notes]] section below.
* Giving a numeric argument //only// results in preformatted text without highlighting but line numbering turned on.
* Giving just a language argument turns on syntax highlighting w/o line numbers.
* Giving a language //and// a numeric argument turns on syntax highlighting //and// line numbering starting with the given number.
* Adding a "''|''", optionally followed by "''h''" or "''f''" and some text will result in a header or footer line attached to the code block (see [[#Behaviour]] below).