enscript to render its output. enscript could handle and render a lot of languages. For a detailed information please read the manual of enscript. You can add your personal code templates by extending the enscript styles. As default there are files like style_xyz.st (e.g. styles_emacs.st). Make a copy and rewrite the output formatting. You can use this later on as the style parameter when calling SyntaxHighlightingPlugin.
To make it easy for people who are using TWiki:Plugins.BeautifierPlugin or TWiki:Plugins.SourceHighlightPlugin there is an option set so that this plugin could also handle %CODE{}% blocks.
Normally enscript will support at least following languages :
show list
hide list
%SYNTAX{ [syntax=]"syntax type" numbered="bool|start with line number" numstep="inc line number" color="bool" style="enscript style"}%
some text belonging to the source code
%ENDSYNTAX%
| SyntaxHighlightingPlugin Parameter | ||
|---|---|---|
| Param | Value | Description |
| style | emacs, msvc | template to format and color your text you can easily create your own styles for enscript |
| [syntax=]"syntax type | cpp | look at "enscript --help-highlight" for a list from enscript param identifier syntax= is optional |
| numbered | on, off, true, false, yes, no 1000 |
will attach an extra source line number a given number will also be the first line number |
| numstep | 10, 100, -50 | increment next line number with the given step counter negative will decrement |
| color | on, off, true, false, yes, no | use color mode to highlight the given text |
%CODE{ "syntax type" }%
some text belonging to the source code
%ENDCODE%
The additional option parameters are also available in this mode.
%SYNTAX{ syntax="cpp" }%
#include <iostream>
int main()
{
std::cout << "Hello, world." << std::endl;
}
%ENDSYNTAX%
gives :
#include <iostream>
int main()
{
std::cout << "Hello, world." << std::endl;
} |
%SYNTAX{ syntax="sh" numbered="1000" numstep="10" }%
#!/bin/sh
list_syntax=`enscript --help-highlight | grep 'Name:' | cut -d ' ' -f 2`
for l in $list_syntax; do
cat << EOF
* $l
EOF
done
%ENDSYNTAX%
which outputs:
01000 #!/bin/sh 01010 list_syntax=`enscript --help-highlight | grep 'Name:' | cut -d ' ' -f 2` 01020 for l in $list_syntax; do 01030 cat << EOF 01040 * $l 01050 EOF 01060 done |
%<plugin>_<setting>%, i.e. %DEFAULTPLUGIN_SHORTDESCRIPTION%
data/debug.txt)
* Set FORMAT_LINENUMBERS = <font color="#555555">%05d</font>	
* Set FORMAT_PREPEND = <table width="100%" border="0" cellpadding="" cellspacing="0"><tr><td bgcolor="#FFFFFF"><pre><font color="#000000">
* Set FORMAT_APPEND = </font></pre></td></tr></table>
SyntaxHighlighting.zip package in your TWiki installation directory.
| Plugin Author: | TWiki:Main.ThomasFreudenberg |
| Previous Authors: | TWiki:Main.NicolasTisserand, TWiki:Main.NicolasBurrus, TWiki:PercevalAnichini |
| Plugin Version: | 24 Nov 2006 |
| Change History: | 24 Nov 2006: completly rewritten |
| CPAN Dependencies: | IPC:Open2 |
| Other Dependencies: | GNU enscript 1.6.3 |
| Perl Version: | 5.0 |
| TWiki:Plugins/Benchmark: | GoodStyle nn%, FormattedSearch nn%, SyntaxHighlightingPlugin nn% |
| Plugin Home: | TWiki:Plugins/SyntaxHighlightingPlugin |
| Feedback: | TWiki:Plugins/SyntaxHighlightingPluginDev |
| Appraisal: | TWiki:Plugins/SyntaxHighlightingPluginAppraisal |