t” for “top”Questo plugin rimpiazza quello già presente nella dokuwiki consentendo di visualizzare i numeri di riga e la possibilita di aggiungere una riga di intestazione ed una di chiusura. Include anche l'evidenziazione per la sintassi Diff.
<code lang 123 |[fh] text |[sh]>
{code to highlight}
</code>
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;|” (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;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.|” (if present) delimits the header/footer text;{code to highlight}” is either the plain text to process or a pointer to an external source.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 …
<code> some text and more </code>
This just renders the given preformatted text without any special highlighting. However,
<code 1> some text and more </code>
will add line numbers in front of each line starting (in this case) with 1 (one).
<code JavaScript 12|Listing 2>
var de = function() {
return (typeof(window.de) == 'object') ? window.de : {};
}();
</code>
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:
<div class="code"> <pre class="code javascript"> <span class="lno">12:</span> <span class="kw2">var</span> de = <span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span> <span class="lno">13:</span> <span class="kw1">return</span> <span class="br0">(</span><span class="kw1">typeof</span><span class="br0">(</span>window.<span class="me1">de</span><span class="br0">)</span> == <span class="st0">'object'</span><span class="br0">)</span> ? window.<span class="me1">de</span> : <span class="br0">{</span><span class="br0">}</span>; <span class="lno">14:</span> <span class="br0">}</span><span class="br0">(</span><span class="br0">)</span>; </pre> <p class="codefoot"><a name="listing_2">Listing 2</a></p> </div>
If you'd rather the text above the code you'd just insert a “h” right after the pipe character i.e. “<code javascript 12|h Listing 2>”.
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”) format5).
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:
<code diff>
--- 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])) {
</code>
To summarize:
|”, 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).