---+!! !SyntaxHighlightingPlugin <!-- One line description, required for extensions repository catalog. * Set SHORTDESCRIPTION = This Plugin is used to emphasize the rendering of your wiki text according to several languages. --> %SHORTDESCRIPTION% %TOC% ---++ Description The Syntax Highlighting Plugin is used to emphasize the rendering of your wiki text according to several languages. It 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: <verbatim> <sticky> %CODE{lang="..." [num="10"]}% ...code... %ENDCODE% </sticky> </verbatim> The language can be any from the above list. The =num= setting is optional and will set the starting line number. The =<sticky>= tags are required to prevent Foswiki's WYSIWYG editor from removing line breaks inside the code block. ---+++ Using %TOPIC% With Other Syntax Highlighters Currently all the Foswiki syntax highlighting plugins use the same =%<nop>CODE%= 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 =$Foswiki::cfg{PluginsOrder}= (or by default, first alphabetically) will consume all the =%<nop>CODE%= blocks. Version 1.2 of this plugin added support for using the %<nop>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 [Foswikitask:Item1353][task report]]. ---+++ Examples The following text : <verbatim> <sticky> %CODE{"c++"}% #include <iostream> int main() { std::cout << "Hello, world." << std::endl; } %ENDCODE% </sticky> </verbatim> gives (if installed): %CODE{"c++"}% #include <iostream> int main() { std::cout << "Hello, world." << std::endl; } %ENDCODE% You can also output numbered lines starting at 10 with this text: <verbatim> <sticky> %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% </sticky> </verbatim> 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 * $l EOF done %ENDCODE% ---+++ Change of Syntax This plugin used to use the following syntax (pre September 2008): <verbatim> <sticky> %begin sh% ...code... %end% </sticky> </verbatim> 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 =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! ---++ 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. Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install". If you have any problems, or if the extension isn't available in =configure=, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help. You should ensure the path to =enscript= is correctly set in =configure= before enabling the plugin. ---++ Plugin Files | *File:* | *Description:* | | ==data/System/SyntaxHighlightingPlugin.txt== | Plugin Topic | | ==lib/Foswiki/Plugins/SyntaxHighlightingPlugin.pm== | Perl Module | | ==lib/Foswiki/Plugins/SyntaxHighlightingPlugin/Config.spec== | Configure Spec | | ==tools/SyntaxHighlightingPlugin_covert.pl== | Script to convert from old syntax to new | ---+++ Plugin Info | Plugin Author(s): | Foswiki:Main.AndrewJones | | Previous Author(s): | TWiki:Main.NicolasTisserand, TWiki:Main.NicolasBurrus, Perceval Anichini | | Copyright: | © 2008 - 2009, Andrew Jones, © 2000 - 2001, Andrea Sterbini, © 2001, Peter Theony | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | Plugin Release: | 1.21 | | Plugin Version: | 9720 (2010-10-25) | | Change History: | <!-- versions below in reverse order --> | | 25 Oct 2010: | 1.21: Documentation updates. -- Foswiki:Main.AndreasKeil, Foswiki:Main.WillNorris | | 07 Jun 2009: | 1.2: Fixed rendering in numbered lists (Foswikitask:Item8176); Moved =configure= setting to Extensions heading -- Foswiki:Main.AndrewJones | | 29 Mar 2009: | 1.1: Added =%<nop>CODE_ENSCRIPT%= syntax so it can be used with other syntax highlighters (Foswikitask:Item1353) -- Foswiki:Main.AndrewJones | | 17 Mar 2009: | 1.0: Initial release for Foswiki (Foswikitask:Item1251) -- Foswiki:Main.AndrewJones | | 11 Sep 2008: | Rewritten to work on TWiki 4.2 (TWikibug:Item5995) -- Foswiki:Main.AndrewJones | | 12 Jul 2002: | Initial version | | Dependencies: | <table class="foswikiTable" border="1"><tr><th>Name</th><th>Version</th><th>Description</th></tr><tr><td align="left">IPC::Run</td><td align="left">>0</td><td align="left">Required</td></tr><tr><td align="left">enscript</td><td align="left">>1.6.4</td><td align="left">Required. Known to work with version 1.6.4 and not with 1.6.1</td></tr></table> | | Plugin Home: | http://foswiki.org/Extensions/%TOPIC% | | Support: | http://foswiki.org/Support/%TOPIC% | __Related Topics:__ %SYSTEMWEB%.DefaultPreferences, %USERSWEB%.SitePreferences, [[%SYSTEMWEB%.Plugins][Plugins]] <!-- Do _not_ attempt to edit this topic; it is auto-generated. Please add comments/questions/remarks to the feedback topic on foswiki.org instead. -->
This topic: System
>
SyntaxHighlightingPlugin
Topic revision:
22 Jun 2007,
ProjectContributor
(raw view)
Copyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki?
Send feedback