deployment1Add my vote for this tag javascript2Add my vote for this tag rendering2Add my vote for this tag syntax_highlighting2Add my vote for this tag create new tag
, view all tags


Client side syntax highlighting using the dp.SyntaxHighlighter


This plugin provides client side syntax highlighting using the dp.SyntaxHighlighter by Alex Gorbatchev. JavaScript needs to be enabled on the clients web browser for this to work.

Syntax Rules

The code goes between the tags %CODE{...}% and %ENDCODE%.

%CODE{...}% can have the following parameters:

Parameter Description
"..." or lang="..." The programming language to be highlighted. See Supported Languages.
nogutter="on" Will not display the gutter.
nocontrols="on" Will not display controls at the top.
collapse="on" Will collapse the block by default.
firstline="value" Will begin line count at value. Default value is 1.
showcolumns="on" Will show row columns in the first line.
el="..." HTML element to display the code in. Can be pre or textarea. Default is pre. See #Pre_vs_Textarea.
Sets the rows and columns attributes.
Recommend if using textarea so the code can be seen clearly when JavaScript is not available.

Pre vs Textarea

There are known problems when displaying XML (and HTML) in a pre element. See http://code.google.com/p/syntaxhighlighter/wiki/PreAndTextarea for more information.

Supported Languages

The following languages are supported:

  • as3, actionscript3
  • css
  • c#, c-sharp, csharp
  • c, cpp, c++
  • vb, vb.net
  • delphi, pascal
  • js, jscript, javascript
  • php
  • py, python
  • ruby
  • sql
  • xml, xhtml, xslt, html, xhtml

Any of these can be used in the lang parameter.


Below is a screen shot of how the rendered code will look.

screenshot of plugin

Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server where TWiki is running.

Like many other TWiki extensions, this module is shipped with a fully automatic installer script written using the BuildContrib.

  • If you have TWiki 4.2 or later, you can install from the configure interface (Go to Plugins->Find More Extensions)
  • If you have any problems, then you can still install manually from the command-line:
    1. Download one of the .zip or .tgz archives
    2. Unpack the archive in the root directory of your TWiki installation.
    3. Run the installer script ( perl <module>_installer )
    4. Run configure and enable the module, if it is a plugin.
    5. Repeat for any missing dependencies.
  • If you are still having problems, then instead of running the installer script:
    1. Make sure that the file permissions allow the webserver user to access all files.
    2. Check in any installed files that have existing ,v files in your existing install (take care not to lock the files when you check in)
    3. Manually edit LocalSite.cfg to set any configuration variables.

If the plugin is installed correcty, the following should be rendered:

%CODE{ lang="javascript" }% function hello () { alert('hello // world'); } %ENDCODE%

Plugin Settings

Plugin Info

Plugin Author: TWiki:Main.AndrewRJones
Copyright: © 2007 TWiki:Main.AndrewRJones
© 2007-2011 TWiki:TWiki.TWikiContributor
License: GPL (GNU General Public License)
Dp Syntax Highlighter Version: 1.5.2 (25 Mar 2008)
Dp Syntax Highlighter License: LGPL (Gnu Lesser General Public License)
Plugin Version: 2011-01-17
Change History:  
2011-01-17: TWikibug:Item6530: Doc improvements; changing TWIKIWEB to SYSTEMWEB; adding screenshot to package -- TWiki:Main.PeterThoeny
25 Mar 2008 1.5.2 -- Arthur Clemens: Added support for ActionScript 3. Thanks to Mark Walters (digitalflipbook.com).
14646 Bugs:Item4460: Fixed adding JS into highlighted HTML (#3)
14642 Bugs:Item4516: Upgrade highlighter to 1.5.1
14046 Bugs:Item4215: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1
Dp Syntax Highlighter Home http://code.google.com/p/syntaxhighlighter
Plugin Home: http://twiki.org/cgi-bin/view/Plugins/DpSyntaxHighlighterPlugin
Feedback: http://twiki.org/cgi-bin/view/Plugins/DpSyntaxHighlighterPluginDev
Appraisal: http://twiki.org/cgi-bin/view/Plugins/DpSyntaxHighlighterPluginAppraisal

Related Topics: TWikiPreferences, TWikiPreferences, TWikiPlugins

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 DpSyntaxHighlighterPlugin.md5 r7 r6 r5 r4 r3 manage 0.2 K 2011-01-18 - 07:23 PeterThoeny  
Compressed Zip archivetgz DpSyntaxHighlighterPlugin.tgz r7 r6 r5 r4 r3 manage 45.0 K 2011-01-18 - 07:23 PeterThoeny  
Compressed Zip archivezip DpSyntaxHighlighterPlugin.zip r7 r6 r5 r4 r3 manage 53.2 K 2011-01-18 - 07:23 PeterThoeny  
Unknown file formatEXT DpSyntaxHighlighterPlugin_installer r6 r5 r4 r3 r2 manage 4.8 K 2011-01-18 - 07:23 PeterThoeny  
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2013-10-16 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.