Loading...
 
Display code with syntax highlighting and line numbering (Cached)

Plugin Code

This wiki plugin is used to display any source code (including wiki syntax) on a page without it being processed. The code is displayed in a gray box in a fixed-width monospaced font. A title can be added to the box and line numbers added. Syntax highlighting is also available, since Tiki7 using CodeMirror and using GeSHi before that.

Parameters

Introduced in Tiki 1.
Preferences required: wikiplugin_code
Parameters Accepted Values Description Default Since
(body of plugin) Code to be displayed
caption text Code snippet label. 1
colors text Any supported language listed at http://codemirror.net/mode/ 17
wrap (blank)
1
0
Wrap lines of code which do not fit in the display box's width. Enabling avoids overflow or hidden line ends. 1
theme default| 3024-day| 3024-night| abcdef| ambiance| ambiance-mobile| base16-dark| base16-light| bespin| blackboard| cobalt| colorforth| dracula| eclipse| elegant| erlang-dark| hopscotch| icecoder| isotope| lesser-dark| liquibyte| material| mbo| mdn-like| midnight| monokai| neat| neo| night| panda-syntax| paraiso-dark| paraiso-light| pastel-on-dark| railscasts| rubyblue| seti| solarized| the-matrix| tomorrow-night-bright| tomorrow-night-eighties| ttcn| twilight| vibrant-ink| xq-dark| xq-light| yeti| zenburn Any supported theme listed at https://codemirror.net/demo/theme.html 17
ln (blank)
1
0
Show line numbers for each line of code. 1
rtl (blank)
1
0
Switch the text display from left to right, to right to left (left to right by default) 1
mediawiki (blank)
1
0
Encloses the code in an HTML code tag, for example: <code>user input<code> 0 8.3

Syntax highlighting

To activate syntax highlighting, the Syntax Highlighting feature must be set at Control Panels > Editing and Plugins > General Settings (tab) > Features (pane).

See the list of CodeMirror supported languages that can be used for the colors parameter.

 Tip
If you need a mode that keeps tab spacing, you can use, for instance, mode scss.

Example

PHP with line numbers

This code:

{CODE(colors="php")}
<?php
$menu = $menubar->getHomeMenu();
if($menu->link != "") {
    print "\t<td width=\"7%\" valign=\"top\">\n";
    $menu->printMenu();
    print "\t</td>\n";
}
{CODE}

Would produce:

<?php
$menu = $menubar->getHomeMenu();
if($menu->link != "") {
    print "\t<td width=\"7%\" valign=\"top\">\n";
    $menu->printMenu();
    print "\t</td>\n";
}

Tiki syntax highlighting

Tiki syntax is supported too.
This code:

{CODE(colors="tiki")}
{img attId="57|58|59" desc="desc" alt="Sample Images"  thumb="y" stylebox="float: left; margin-right:10px"}
{CODE}

Would produce:

{img attId="57|58|59" desc="desc" alt="Sample Images"  thumb="y" stylebox="float: left; margin-right:10px"}

Legacy GeSHi Documentation (deprecated in Tiki8)

[+]

Aliases

Plugin Code

Attached files

ID Name Comment Uploaded Size Downloads
49 codenogeshi.png Code no geshi lindon 20.39 Kb 9231