---+!! <nop>%TOPIC% <!-- Contributions to this TWiki plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/BeautifierPlugin or provide feedback at http://twiki.org/cgi-bin/view/Plugins/BeautifierPluginDev. If you are a TWiki contributor please update the plugin in the SVN repository. --> <sticky><div style="float:right; background-color:#EBEEF0; margin:0 0 20px 20px; padding: 0 10px 0 10px;"> %TOC{title="Page contents"}% </div></sticky> %SHORTDESCRIPTION% ---++ Introduction This plugin allows you to have code fragments automatically formatted and highlighted. It uses the Beautifier library (included) written by Mike Jewell. ---++ Syntax Rules Insert the code between =%<nop>CODE{"<i>language</i>"}%= and =%<nop>ENDCODE%=. The following table indicates the values used for the different languages: <blockquote> | *Language* | *Syntax* | | bash | =%<nop>CODE{"bash"}%= ... =%<nop>ENDCODE%= | | C++ | =%<nop>CODE{"cpp"}%= ... =%<nop>ENDCODE%= | | C# | =%<nop>CODE{"csharp"}%= ... =%<nop>ENDCODE%= | | Corba | =%<nop>CODE{"corba"}%= ... =%<nop>ENDCODE%= | | CSS | =%<nop>CODE{"css"}%= ... =%<nop>ENDCODE%= | | HTML | =%<nop>CODE{"html"}%= ... =%<nop>ENDCODE%= | | IDL | =%<nop>CODE{"idl"}%= ... =%<nop>ENDCODE%= | | Java | =%<nop>CODE{"java"}%= ... =%<nop>ENDCODE%= | | <nop>JavaScript | =%<nop>CODE{"javascript"}%= ... =%<nop>ENDCODE%= | | Lua | =%<nop>CODE{"lua"}%= ... =%<nop>ENDCODE%= | | Makefile | =%<nop>CODE{"makefile"}%= ... =%<nop>ENDCODE%= | | Perl | =%<nop>CODE{"perl"}%= ... =%<nop>ENDCODE%= | | PHP3 | =%<nop>CODE{"php3"}%= ... =%<nop>ENDCODE%= | | PL/SQL | =%<nop>CODE{"plsql"}%= ... =%<nop>ENDCODE%= | | Python | =%<nop>CODE{"python"}%= ... =%<nop>ENDCODE%= | | Scheme | =%<nop>CODE{"scheme"}%= ... =%<nop>ENDCODE%= | | TCL | =%<nop>CODE{"tcl"}%= ... =%<nop>ENDCODE%= | | Visual Basic | =%<nop>CODE{"vb"}%= ... =%<nop>ENDCODE%= | | Verilog | =%<nop>CODE{"verilog"}%= ... =%<nop>ENDCODE%= | | VHDL | =%<nop>CODE{"vhdl"}%= ... =%<nop>ENDCODE%= | | XML | =%<nop>CODE{"xml"}%= ... =%<nop>ENDCODE%= | </blockquote> 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. ---+++ Display Customisation The code fragments are formaated using CSS. To change the look, upload a new version of [[%PUBURL%/%WEB%/%TOPIC%/style.css][style.css]] to this topic. ---++ Examples <blockquote> <pre> %<nop>CODE{"cpp"}% void foo() { print("Do stuff.\n"); } %ENDCODE% </pre> </blockquote> ---++ <nop>%TOPIC% Global Settings Plugin settings are stored as preferences variables. To reference a plugin setting write ==%<nop><plugin>_<setting>%==, i.e. ==%<nop>BEAUTIFIERPLUGIN_SHORTDESCRIPTION%== * One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic: * Set SHORTDESCRIPTION = Highlight and format source code fragments of various languages ---++ Plugin Installation Instructions __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. * For an __automated installation__, run the [[%SCRIPTURL{configure}%][configure]] script and follow "Find More Extensions" in the in the __Extensions__ section. * Optionally, move the =lib/Beautifier=, =lib/Output= and =lib/HFile= libraries into the Perl library folder. * Or, follow these __manual installation__ steps: * Download the ZIP file from the Plugins home (see below). * Unzip ==%TOPIC%.zip== in your twiki installation directory. Content: | *File:* | *Description:* | | ==data/TWiki/%TOPIC%.txt== | Plugin topic | | ==data/TWiki/VarCODE.txt== | CODE variable documentation topic | | ==pub/TWiki/%TOPIC%/style.css== | Default CSS | | ==lib/TWiki/Plugins/%TOPIC%.pm== | Plugin Perl module | | ==lib/Beautifier/*.pm== | Perl modules | | ==lib/HFile/*.pm== | Perl modules | | ==lib/Output/*.pm== | Perl modules | * Optionally, move the =lib/Beautifier=, =lib/Output= and =lib/HFile= libraries into the Perl library folder. * Set the ownership of the extracted directories and files to the webserver user. * Plugin __configuration and testing__: * Run the [[%SCRIPTURL{configure}%][configure]] script, enable the plugin in the __Plugins__ section * Configure the plugin: See plugin settings above. * Test if the installation was successful: %CODE{"cpp"}% #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); } } %ENDCODE% %CODE{"unknown"}% testing an invalid language setting... %ENDCODE% ---++ Plugin Info | Plugin Author: | TWiki:Main.LingLo | | Copyright: | © 2002-2007 TWiki:Main.LingLo <br /> © 2007-2012 TWiki:TWiki.TWikiContributor | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | Plugin Version: | 2012-12-02 | | Change History: | <!-- specify latest version first --> | | 2012-12-02: | TWikibug:Item7020: Add category to VarCODE; doc improvements -- TWiki:Main.PeterThoeny| | 2011-01-03: | TWikibug:Item6530: Doc improvements; small style improvement; changing TWIKIWEB to SYSTEMWEB; adding CORBA (thanks Will Norris), IDL (thanks Will Norris), Visual Basic (thanks TWiki:Main.ThomasJachmann), CSS -- TWiki:Main.PeterThoeny | | 2007-05-20: | added <nop>JavaScript language file, removed legacy CODE_<i>lang</i> 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 support -- TWiki:Main.WillNorris | | 2003-07-26: | Syntax fixes from TWiki:Main.WillNorris -- TWiki:Main.LingLo | | 2003-02-26: | Syntax fix from TWiki:Main.JoshMore -- TWiki:Main.LingLo | | 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 ([[http://www.beautifier.org][Beautifier]] is included) | | Perl Version: | 5.005 | | Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% | | Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev | __Related Topics:__ VarCODE, %SYSTEMWEB%.TWikiPreferences, %SYSTEMWEB%.TWikiPlugins
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
css
style.css
r9
r8
r7
r6
r5
manage
0.2 K
2020-12-07 - 04:40
JeffreyBarrick
Saved by install script
This topic: TWiki
>
BeautifierPlugin
Topic revision: r3 - 2020-12-07 - JeffreyBarrick
Copyright © 1999-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback
Note:
Please contribute updates to this topic on TWiki.org at
TWiki:TWiki.BeautifierPlugin
.