DokuWiki

It's better when it's simple

User Tools

Site Tools


syntax_highlighting

Syntax Highlighting

DokuWiki includes support for code syntax highlighting as described at the syntax page.

Starting with DokuWiki release “Greebo” some additional GeShi options for syntax highlighting are supported:

  • Enable line numbers: enable_line_numbers="true"
  • Start line numbers at line n: start_line_numbers_at="42"
  • Highlight certain lines extra: highlight_lines_extra="2,5"
  • Disable keyword linking to appropriate documentation: enable_keyword_links="false"

All options are set by adding some key-value pairs to the standard code-tag syntax.

<code languagecode [key="value", ...]>

The following examples explain their usage.

Examples

The following code enables line numbers:

<code JavaScript [enable_line_numbers="true"]>
var de = function() {
	return (typeof(window.de) == 'object') ? window.de : {};
}();
</code>

This is the result:

  1. var de = function() {
  2. return (typeof(window.de) == 'object') ? window.de : {};
  3. }();

The next example additionally highlights one line:

<code JavaScript [enable_line_numbers="true",highlight_lines_extra="2"]>
var de = function() {
	return (typeof(window.de) == 'object') ? window.de : {};
}();
</code>

This is the result:

  1. var de = function() {
  2. return (typeof(window.de) == 'object') ? window.de : {};
  3. }();

You can also highlight multiple lines:

<code JavaScript [enable_line_numbers="true",highlight_lines_extra="2,3"]>
var de = function() {
	return (typeof(window.de) == 'object') ? window.de : {};
}();
</code>

This is the result:

  1. var de = function() {
  2. return (typeof(window.de) == 'object') ? window.de : {};
  3. }();

Line numbers can start at any given value:

<code C [enable_line_numbers="true", start_line_numbers_at="42"]>
void main () {
    printf ("Hello World!");
    exit(0);
}
</code>

This is the result:

  1. void main () {
  2. printf ("Hello World!");
  3. exit(0);
  4. }

In some languages certain keywords link to appropriate online documentation. This can be disabled:

<code C [enable_keyword_links="false"]>
void main () {
    printf ("Hello World!");
    exit(0);
}
</code>

This is the result:

void main () {
    printf ("Hello World!");
    exit(0);
}
syntax_highlighting.txt · Last modified: by schplurtz

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki