[Show/Hide Right Column]

Display code syntax with line numbers and color highlights
Print

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 the code can be highlighted and line numbers added.

If a third party program called GeSHi (Generic Syntax Highlighter) has been installed on the Tiki site by the administrator, then the highligting feature is greatly enhanced. Without GeSHi, only php syntax can be highlighted and only when line numbering is turned off. With GeSHi (stable version), over 110 languages can be highlighted and used together with line numbering. Also with GeSHi (stable version), key terms in the code will be linked to the documentation page explaining the term on that language's web site.

The plugin will escape syntax, preventing tiki from accidentally parsing them, but there are a few difficult areas that you need to beware of. XML or SGML syntax may cause a hiccup if you have enabled the HTML flag on the document. This also means that you must be wary with the greater than , or less than signs.



Usage

To display code in a wiki page, use the syntax:
{CODE()}
{CODE(colors=php ln="1")}
getHomeMenu();
if($menu->link != "") {
print "\t\n";
$menu->printMenu();
print "\t\n";
}
{CODE}{CODE}


And if you have not figured it out yet, the example of the use of the code plugin, actually uses the code plugin - neat eh? You can recurse code tags, and it will simply render all those but the ending one. Beware: this will cause a problem if you mismatch them.

Parameters

Parameter Accepted values Effect Since
ln without GeSHi: 0 or 1 Adds line numbering when set to 1. Warning: Doesn't work when colors parameter is also set.
with GeSHi: any number Adds line numbering starting with the number given. Also works when colors parameter is set
colors without GeSHi: php or highlights Adds code syntax color highlighting for php (only). The php tag must be included at the beginning of the displayed code for the highlighting to work. The colors and ln parameters do not work together.
with GeSHi: any language name that GeSHI supports (like php, javascript, css, html). See below for more information on GeSHi. Adds color highlighting of the code syntax and key terms are linked to the documentation page on the language's site. No need to include beginning tags for the highlighting to work. Can be used together with line numbering.
caption 0 or 1 This allows you to provide a caption for the code box
wrap 0 or 1 This enables line wrapping on the code, if necessary.
wiki 0 or 1 This enables wiki interpretation of the code, otherwise wiki style markup in the code is left alone.
rtl 0 or 1 This enables the right to left display of text
ishtml 0 or 1 When set to 1, HTML will still be processed


Example Without GeSHi

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 display:
Image

noteNote
For the color highlighting to work for php when GeSHi is not installed, it's important to include the php tag at the beginning.


GeSHi - Generic Syntax Highlighter

Supported Languages

Since Tiki 2.0., if the GeSHi package is installed additionally in the server, then many markups will be recognized and highlighted accordingly:

noteNote
Be careful to install the latest stable version and not the latest development version of GeSHi, otherwise only a few languages will be available and functionality will suffer.


  • ABAP
  • Actionscript
  • ADA
  • Apache Log
  • AppleScript
  • APT sources.list
  • ASM (m68k)
  • ASM (pic16)
  • ASM (x86)
  • ASM (z80)
  • ASP
  • AutoIT
  • Backus-Naur form
  • Bash
  • Basic4GL
  • BlitzBasic
  • Brainfuck
  • C
  • C for Macs
  • C#
  • C++
  • C++ (with QT)
  • CAD DCL
  • CadLisp
  • CFDG
  • CIL / MSIL
  • COBOL
  • ColdFusion
  • CSS
  • D
  • Delphi
  • Diff File Format
  • DIV
  • DOS
  • DOT language
  • Eiffel
  • Fortran
  • FourJ's Genero
  • FreeBasic
  • GetText
  • glSlang
  • GML
  • gnuplot
  • Groovy
  • Haskell
  • HQ9+
  • HTML
  • INI (Config Files)
  • Inno
  • INTERCAL
  • IO
  • Java
  • Java 5
  • Javascript
  • KiXtart
  • KLone C & C++
  • LaTeX
  • Lisp
  • LOLcode
  • LotusScript
  • LScript
  • Lua
  • Make
  • mIRC
  • MXML
  • MySQL
  • NSIS
  • Objective C
  • OCaml
  • OpenOffice BASIC
  • Oracle 8 & 11 SQL
  • Pascal
  • Perl
  • PHP
  • Pixel Bender
  • PL/SQL
  • POV-Ray
  • PowerShell
  • Progress (OpenEdge ABL)
  • Prolog
  • ProvideX
  • Python
  • Q(uick)BASIC
  • robots.txt
  • Ruby
  • Ruby on Rails
  • SAS
  • Scala
  • Scheme
  • Scilab
  • SDLBasic
  • Smalltalk
  • Smarty
  • SQL
  • T-SQL
  • TCL
  • thinBasic
  • TypoScript
  • Uno IDL
  • VB.NET
  • Verilog
  • VHDL
  • VIM Script
  • Visual BASIC
  • Visual Fox Pro
  • Visual Prolog
  • Whitespace
  • Winbatch
  • Windows Registry Files
  • X++
  • XML
  • Xorg.conf


To be certain which languages your installation of GeSHi covers, check the language files in directory where GeSHi was installed.

Installing GeSHi

Since GeSHi has been licensed under GPL - which is incompatible with Tikiwiki's LGPL licence - the administrator will need to manually download http://qbnz.com/highlighter and copy GeSHI in your own tikiwiki's lib/geshi/ directory. You can also install the stable version of GeSHI with the Debian/Ubuntu package "php-geshi".

It is recommended to install the latest stable version of GeSHi (not the latest development version) because the stable version handles many more languages and has more functionality.

Examples with GeSHi


This code:
{CODE(ln=1 colors=html4strict)}
<!-- HTML example with GeSHi installed-->
<html>
    <head>
        <title>Hi!</title>
    </head>
    <body>
        <div id="content" class="foo">
            <p>This is the content of the page.</p>
            A&nbsp; &nbsp;...&nbsp; &nbsp; Z
        </div>
    </body>
&ndash;
</html>
{CODE}


Would produce:
Image
Screenshot of the output


Which should be the same to the real-time output in doc.tw.o once the geshi package is properly installed:

1
2
3
4
56
7
8
9
1011
12
13
<!-- HTML example with GeSHi installed-->
<html>
    <head>
        <title>Hi!</title>
    </head>    <body>
        <div id="content" class="foo">
            <p>This is the content of the page.</p>
            A&nbsp; &nbsp;...&nbsp; &nbsp; Z
        </div>    </body>
&ndash;
</html>


noteNote
To highlight HTML, the colors parameter needs to be set to "html4strict" when using the stable version of GeSHi. The exact spelling required for a language is determined by the name of the language file in the GeSHi directory.




Contributors to this page: lindon2179 points  , Xavi33852 points  , Danny Staple13 points  , Marc Laporte5242 points  , Greg Martin48 points  , dthacker1311 points  and Jean-Fran720 points  .
Page last modified on Saturday 10 July, 2010 03:40:45 UTC by lindon2179 points .

Find by Page Name

Exact match

Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki documentation and should correspond to development keywords (bug reports and feature requests):

Accessibility (WAI & 508)
Articles & Submissions
Backlinks
Banners
Batch
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Link Cache
Calendar
Category
Chat
Clean URLs
Comments
Communication Center
Compression (gzip)
Contacts Address book
Contact us
Content template
Contribution 2.x
Cookie
Copyright
Custom Home (and Groups Home Page)
Date and Time
Debugger Console
Directory (of hyperlinks)
Documentation link from Tiki to doc.tikiwiki.org (Help System)
DogFood
Dynamic Content
Dynamic Variable
External Authentication
FAQ
Featured links
File Gallery
Forum
Friendship Network (Community)
Gmap Google maps
Groups
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interaction
Inter-User Messages
InterTiki
Kaltura video editing
Karma
Live Support
Login
Logs (system & action)
Look and Feel
Lost edit protection
Mail-in
Map with Mapserver
Menu
Meta Tags
Mobile Tiki and Voice Tiki
Mods
Module
MultiTiki
MyTiki
Newsletter
Notepad
Payment
Performance Speed / Load
Permissions
Platform independence (Linux-Apache, Windows/IIS, Mac, BSD)
Polls
Profiles
Profile Manager
Quicktags
Quiz
Rating
Feeds
Score
Search engine optimization
Search
Security
Semantic links 3.x
Shadowbox
Shadow Layers
Shopping cart
Shoutbox
Slideshow
Smiley
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Stats
Surveys
Tags 2.x
Task
Tell a Friend, Alert + Social Bookmarking
TikiTests 2.x
Theme CSS & Smarty
Trackers
TRIM
User Administration including registration and banning
User Files
User Menu
Watch
WebHelp
WebDAV 5.x
Webmail
Webservices
Wiki 3D
Wiki History, page rename, etc
Wiki Page Staging and Approval 2.x
Wiki Plugin extends basic syntax
Wiki Syntax
Wiki structure (book and table of content)
Workspace
WYSIWYCA
WYSIWYG 2.x
XMLRPC