Highlights code fragments for many languages using
The Syntax Highlighting Plugin is used to emphasize the rendering of your wiki text according to several languages.
to render its output.
It supports the following languages :
- cpp (c++)
- fortran_pp (fortran77)
To use this plugin, use the following syntax:
The language can be any from the above list. The
setting is optional and will set the starting line number.
tags to prevent Foswiki's WYSIWYG
editor from removing line breaks inside the code block:
... code ...
Currently all the Foswiki syntax highlighting plugins use the same
syntax. This allows you to switch the highlighter you use without having to update all your topics to the new syntax. However, it also means that if you have two or more highlighting plugins installed on your system, the plugin that is first in
(or by default, first alphabetically) will consume all the
Version 1.2 of this plugin added support for using the %CODE_ENSCRIPT% syntax, which allows you to explicitly which plugin you want to highlight your code.
Clearly this is not the best solution to the problem of using more than one highlighting plugin. You can read the background on why this approach was taken in the task report
The following text:
std::cout << "Hello, world." << std::endl;
gives (if installed):
unknown language c++
You can also output numbered lines starting at 10 with this text:
languages=`enscript --help-highlight | grep 'Name:' | cut -d ' ' -f 2`
for l in $languages; do
cat << EOF
gives (if installed):
11 languages=`enscript --help-highlight | grep 'Name:' | cut -d ' ' -f 2`
12 for l in $languages; do
13 cat << EOF
14 * $l
Change of Syntax
This plugin used to use the following syntax (pre September 2008):
This has been changed to be more consistent with other Foswiki variables. There
is a script included which will replace the old syntax with the new. To use it,
copy it from the
directory and into your
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!
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.
Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button.
Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will not
show up in the
You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
perl tools/extension_installer <NameOfExtension> install
If you have any problems, or if the extension isn't available in
, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions
for more help.
You should ensure the path to
is correctly set in
before enabling the plugin.
|enscript||>1.6.4||Required. Known to work with version 1.6.4 and not with 1.6.1|