Syntax Highlighting Plugin
The Syntax Highlighting Plugin is used to emphasize the rendering of your wiki text according to several languages.
It currently uses
enscript
to render its output.
It supports the following languages :
- ada
- asm
- awk
- bash
- c
- changelog
- c++
- csh
- delphi
- diff
- diffs
- diffu
- elisp
- fortran
- fortran_pp
- haskell
- html
- idl
- inf
- java
- javascript
- ksh
- m4
- mail
- makefile
- maple
- matlab
- modula_2
- nested
- nroff
- objc
- outline
- pascal
- perl
- postscript
- python
- rfc
- scheme
- sh
- skill
- sql
- states
- synopsys
- tcl
- tcsh
- tex
- vba
- verilog
- vhdl
- vrml
- wmlscript
- zsh
Syntax Rules
To use this plugin, use the following syntax:
%CODE{lang="..." [num="10"]}%
...code...
%ENDCODE%
The language can be any from the above list. The
num
setting is optional and
will set the starting line number.
Examples
The following text :
%CODE{"c++"}%
#include <iostream>
int main()
{
std::cout << "Hello, world." << std::endl;
}
%ENDCODE%
gives (if installed):
%CODE{"c++"}%
#include
int main()
{
std::cout << "Hello, world." << std::endl;
}
%ENDCODE%
You can also output numbered lines starting at 10 with this text:
%CODE{"sh" num="10"}%
#!/bin/sh
languages=`enscript --help-highlight | grep 'Name:' | cut -d ' ' -f 2`
for l in $languages; do
cat << EOF
* $l
EOF
done
%ENDCODE%
gives (if installed):
%CODE{"sh" num="10"}%
#!/bin/sh
languages=`enscript --help-highlight | grep 'Name:' | cut -d ' ' -f 2`
for l in $languages; do
cat << EOF
EOF
done
%ENDCODE%
Plugin Settings
Use configure to change the settings for this plugin.
Change of Syntax
This plugin used to use the following syntax:
%begin sh%
...code...
%end%
This has been changed to be more consistent with other twiki variables. There is a script included which will replace the old syntax with the new. To use it, copy it from the tools
directory and into your data
directory. When you run it, it will look through your webs and replace the syntax. Note that its not the best script in the world, so always test it on a copy of your data first!
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:
- Download one of the
.zip
or .tgz
archives
- Unpack the archive in the root directory of your TWiki installation.
- Run the installer script (
perl <module>_installer
)
- Run
configure
and enable the module, if it is a plugin.
- Repeat for any missing dependencies.
- If you are still having problems, then instead of running the installer script:
- Make sure that the file permissions allow the webserver user to access all files.
- 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)
- Manually edit LocalSite.cfg to set any configuration variables.
Plugin Files
data/TWiki/SyntaxHighlightingPlugin.txt |
Plugin Topic |
lib/TWiki/Plugins/SyntaxHighlightingPlugin.pm |
Perl Module |
lib/TWiki/Plugins/SyntaxHighlightingPlugin/Config.spec |
|
tools/SyntaxHighlightingPlugin_covert.pl |
|
Plugin Info
Related Topics: TWikiPreferences, TWikiPlugins