Source Highlighting Plugin

Highlight your source code! This plugin uses highlight.

Syntax Rules

Enclose your code within <highlight></highlight> tags.

Include the following options within the opening highlight tag:
  • lang - Specify the code language to highlight; use the language's extension (defaults to r).
  • bgcolor - Specify the backround color (defaults to light blue).
  • keywords - Specify additional keywords (quoted and semicolon delimited) to highlight. (ex: keywords="upData;radFunction")

Available Languages

See this for the full listing. I'll try to get the extensions for each language.

Example

<highlight>
a<-function(data) {
   plot(data)
}
</highlight>

a<-function(data) {
   plot(data)
}

<highlight bgcolor=#cccccc lang=py keywords="write;xreadlines">
#!/usr/bin/python
# this script replaces all occurrences of char old with char new
import os, sys
old='\n'
new=' '
file='~/names.txt'
input=open(file)
output=open(file+'.new','w')
for s in input.xreadlines():
    output.write(s.replace(old,new))
output.close()
input.close()
</highlight>

SourceHighlighting Error: unknown error

SourceHighlightingPlugin Global Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, for example, %EMPTYPLUGIN_SHORTDESCRIPTION%

  • One line description, shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = This plugin highlights source code.

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

Plugin Installation Instructions

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

  • Download the ZIP file from the Plugin web (see below)
  • Unzip SourceHighlightingPlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/SourceHighlightingPlugin.txt Plugin topic
    data/TWiki/SourceHighlightingPlugin.txt,v Plugin topic repository
    lib/TWiki/Plugins/SourceHighlightingPlugin.pm Plugin Perl module
  • Test if the plugin is correctly installed:
    • (describe tests here)

Plugin Info

Plugin Author: ColeBeck
Plugin Version: 10 Jan 2006 (V1.200)
Change History:  
7 Oct 2005: Initial version
11 Oct 2005: Can highlight any language available + bgcolor
10 Jan 2002: Can specify additional keywords to highlight (JS)
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
Plugin Home:  

-- ColeBeck - 11 Oct 2005
Topic revision: r8 - 29 Jul 2008, ColeBeck
 

This site is powered by FoswikiCopyright © 2013-2020 by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback