This plugin allows you to have code fragments automatically formatted and highlighted. It uses the Beautifier library (included) written by Mike Jewell.
Insert the code between %CODE{"language"}%
and %ENDCODE%
. The following table indicates the values used for the different languages:
Language Syntax bash %CODE{"bash"}%
...%ENDCODE%
C++ %CODE{"cpp"}%
...%ENDCODE%
C# %CODE{"csharp"}%
...%ENDCODE%
Corba %CODE{"corba"}%
...%ENDCODE%
CSS %CODE{"css"}%
...%ENDCODE%
HTML %CODE{"html"}%
...%ENDCODE%
IDL %CODE{"idl"}%
...%ENDCODE%
Java %CODE{"java"}%
...%ENDCODE%
JavaScript %CODE{"javascript"}%
...%ENDCODE%
Lua %CODE{"lua"}%
...%ENDCODE%
Makefile %CODE{"makefile"}%
...%ENDCODE%
Perl %CODE{"perl"}%
...%ENDCODE%
PHP3 %CODE{"php3"}%
...%ENDCODE%
PL/SQL %CODE{"plsql"}%
...%ENDCODE%
Python %CODE{"python"}%
...%ENDCODE%
Scheme %CODE{"scheme"}%
...%ENDCODE%
TCL %CODE{"tcl"}%
...%ENDCODE%
Visual Basic %CODE{"vb"}%
...%ENDCODE%
Verilog %CODE{"verilog"}%
...%ENDCODE%
VHDL %CODE{"vhdl"}%
...%ENDCODE%
XML %CODE{"xml"}%
...%ENDCODE%
Additional languages can be added since the Beautifier library is flexible and can support a wide range of language families. Other languages can be added with relative ease by downloading the full PHP dist from http://sourceforge.net/projects/beautifier/ and converting the relevant language file from PHP to Perl. Note: The original http://www.beautifier.org/
website is defunct.
The code fragments are formaated using CSS. To change the look, upload a new version of style.css to this topic.
%CODE{"cpp"}% void foo() { print("Do stuff.\n"); } %ENDCODE%
Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%
, i.e. %BEAUTIFIERPLUGIN_SHORTDESCRIPTION%
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 TWiki server.
lib/Beautifier
, lib/Output
and lib/HFile
libraries into the Perl library folder.
BeautifierPlugin.zip
in your twiki installation directory. Content: File: | Description:![]() |
---|---|
data/TWiki/VarCODE.txt | CODE variable documentation topic |
pub/TWiki/BeautifierPlugin/style.css | Default CSS |
lib/Beautifier/*.pm | Perl modules |
lib/HFile/*.pm | Perl modules |
lib/Output/*.pm | Perl modules |
lib/TWiki/Plugins/BeautifierPlugin.pm | Plugin Perl module |
data/TWiki/BeautifierPlugin.txt | Plugin topic |
lib/Beautifier
, lib/Output
and lib/HFile
libraries into the Perl library folder.
#include <nworld.h> /** @brief Advance the simulation by one timeslice. */ void nWorld::StepSim() { // Iterate simulation loop for (node = entityList.GetHead(); node != NULL; node = node->GetSucc()) { entity = (nEntity*)node->GetPtr(); entity->Trigger(this, this->stepSize); } }
BeautifierPlugin Error: Unable to handle "unknown" language.
testing an invalid language setting...
Plugin Author: | TWiki:Main.LingLo![]() |
Copyright: | © 2002-2007 TWiki:Main.LingLo![]() © 2007-2012 TWiki:TWiki.TWikiContributor ![]() |
License: | GPL (GNU General Public License![]() |
Plugin Version: | 2012-12-02 |
Change History: | |
2012-12-02: | TWikibug:Item7020![]() ![]() |
2011-01-03: | TWikibug:Item6530![]() ![]() ![]() |
2007-05-20: | added JavaScript language file, removed legacy CODE_lang construct -- TWiki:Main.WillNorris![]() |
2007-04-30: | warnings cleanup; no functional changes -- TWiki:Main.WillNorris![]() |
2007-04-27: | automatically adds CSS for formatting code fragments -- TWiki:Main.WillNorris![]() |
2006-01-01: | upgraded to TWiki::Func::extractNameValuePair for better parameter parsing, upgraded TWiki:Plugins.BuildContrib![]() ![]() |
2003-07-26: | Syntax fixes from TWiki:Main.WillNorris![]() ![]() |
2003-02-26: | Syntax fix from TWiki:Main.JoshMore![]() ![]() |
2002-12-28: | Accepts mixed case language names -- TWiki:Main.LingLo![]() |
2002-12-20: | Changed syntax to allow for simpler addition of new languages -- TWiki:Main.LingLo![]() |
2002-10-16: | Added nebula nodes and links to Python scripts, but it doesn't work since the node names are usually in strings -- TWiki:Main.LeafGarland![]() |
2002-07-30: | Added nebula nodes and links to TCL scripts -- TWiki:Main.LeafGarland![]() |
2002-07-30: | Changed Beautifier::Core to use 'linkscripts' -- TWiki:Main.LeafGarland![]() |
2002-07-28: | Created -- TWiki:Main.LingLo![]() |
CPAN Dependencies: | none |
Other Dependencies: | none (Beautifier![]() |
Perl Version: | 5.005 |
Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/BeautifierPlugin![]() |
Feedback: | http://TWiki.org/cgi-bin/view/Plugins/BeautifierPluginDev![]() |
Related Topics: VarCODE, TWikiPreferences, TWikiPlugins