History: PluginCode
Source of version: 94 (current)
Copy to clipboard
! 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. {REMARKSBOX(type="warning" title="Note about Wiki Argument Variables")}((Wiki argument variables)) like -+~np~{~/np~{page}}+- will be interpreted inside any wiki plugin or wiki syntax. To display a wiki argument variable you can escape the first bracket using the -+np+- (non parseable) tag: -+~n~np~p~/np~~{~/np~{page}}+-.{REMARKSBOX} !! Parameters {pluginmanager plugin="code"} !!! Syntax highlighting To activate syntax highlighting and enjoy most of the options (lines number, colors, etc), the Code editor (CodeMirror) feature must be enabled at -+Control Panels > Editing and Plugins > General Settings (tab) > Features (pane)+-. See the list of [http://codemirror.net/mode/|CodeMirror] supported languages that can be used for the -+colors+- parameter. {REMARKSBOX(type="tip" title="Tip")}If you need a mode that keeps tab spacing, you can use, for instance, mode -+scss+-.{REMARKSBOX} !! Example !!! PHP with line numbers ''This code:'' {CODE(wrap=1)} {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}{CODE} ''Would produce:'' {CODE(colors="php" ln="1")} <?php $menu = $menubar->getHomeMenu(); if($menu->link != "") { print "\t<td width=\"7%\" valign=\"top\">\n"; $menu->printMenu(); print "\t</td>\n"; } {CODE} !!Tiki syntax highlighting Tiki syntax is supported too. ''This code:'' {CODE(wrap=1)} {CODE(colors="tiki")} {img attId="57|58|59" desc="desc" alt="Sample Images" thumb="y" stylebox="float: left; margin-right:10px"} {CODE}{CODE} ''Would produce:'' {CODE(colors="tiki")} {img attId="57|58|59" desc="desc" alt="Sample Images" thumb="y" stylebox="float: left; margin-right:10px"} {CODE} !!- Legacy GeSHi Documentation (deprecated in Tiki8) Starting in ((Tiki7)), ((CodeMirror)) was added as experimental for Syntax Highlighting, and in ((Tiki8)), it became the default syntax highlighting. [http://thread.gmane.org/gmane.comp.cms.tiki.devel/22887|Geshi is no longer supported]. {REMARKSBOX(type=note title=Note)}''For the color highlighting to work for php when GeSHi is not installed and you are using ((Tiki6)) or earlier versions, it's important to include the php tag at the beginning.'' {REMARKSBOX} !!! Installing GeSHi Since GeSHi has been licensed under GPL - which is incompatible with Tiki's LGPL license - the administrator will need to manually download a copy of GeSHI. It appears the project now uses [https://github.com/GeSHi|GitHub] for the repository. Once you have you copy of Geshi, you should place it in your own tiki's lib/geshi/ directory, so that once placed there the folder structure is something like: {CODE()} ./lib/geshi/contrib/ ./lib/geshi/docs/ ./lib/geshi/geshi/ ./lib/geshi/geshi.php {CODE} You could alternatively install the stable version of GeSHI with the Debian/Ubuntu package -+php-geshi+- (check if the version of the package is fresh enough for your needs, compared to the latest stable from their website or subversion repository). !!! Supported languages To be certain which languages your installation of GeSHi covers, check the language files in directory where GeSHi was installed. See the [https://github.com/GeSHi/geshi-1.0/tree/master/src/geshi|this GitHub repository language folder] for example. The exact name of the language file (without the .php extension) is used to specify the language in the -+colors+- parameter. !! Related pages * [http://qbnz.com/highlighter/|GeSHi - Generic Syntax Highlighter] * ((Syntax Highlighter)) * [http://codemirror.net|CodeMirror] !!Aliases (alias(Plugin Code))