(file) Return to SyntaxHighlightingPlugin.txt CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / twiki / data / TWiki

  1 rizwank 1.1 %META:TOPICINFO{author="RizwanKassim" date="1105766322" format="1.0" version="1.2"}%
  2             %META:TOPICPARENT{name="TWikiPreferences"}%
  3             ---++ Syntax Highlighting TWiki Plugin
  4             
  5             The Syntax Highlighting Twiki Plugin is used to emphasize the rendering of your twiki text according to several languages.
  6             
  7             It currently uses =enscript= to render its output.
  8             
  9             It supports the following languages : 
 10             	* ada
 11             	* asm
 12             	* awk
 13             	* bash
 14             	* c
 15             	* changelog
 16             	* c++
 17             	* csh
 18             	* delphi
 19             	* diff
 20             	* diffs
 21             	* diffu
 22 rizwank 1.1 	* elisp
 23             	* fortran
 24             	* fortran_pp
 25             	* haskell
 26             	* html
 27             	* idl
 28             	* inf
 29             	* java
 30             	* javascript
 31             	* ksh
 32             	* m4
 33             	* mail
 34             	* makefile
 35             	* maple
 36             	* matlab
 37             	* modula_2
 38             	* nested
 39             	* nroff
 40             	* objc
 41             	* outline
 42             	* pascal
 43 rizwank 1.1 	* perl
 44             	* postscript
 45             	* python
 46             	* rfc
 47             	* scheme
 48             	* sh
 49             	* skill
 50             	* sql
 51             	* states
 52             	* synopsys
 53             	* tcl
 54             	* tcsh
 55             	* tex
 56             	* vba
 57             	* verilog
 58             	* vhdl
 59             	* vrml
 60             	* wmlscript
 61             	* zsh
 62             
 63             ---+++ Syntax Rules
 64 rizwank 1.1 
 65             To enable syntax highlighting on some text, just type :
 66             
 67             <verbatim>%begin [numbered] language% 
 68             
 69             	 some text belonging to the language
 70             
 71             %end%</verbatim> where language is one of the list above, and numbered an optional keyword triggering the line numbering feature.
 72             
 73             Notice that the =%begin language%= and =%end%= must be left alone on one single line.
 74             
 75             ----+++ Example
 76             
 77             The following text :
 78             
 79             <verbatim>%begin c++% 
 80             #include <iostream>
 81             int main()
 82             {
 83               std::cout << "Hello, world." << std::endl;
 84             }
 85 rizwank 1.1 %end% </verbatim>
 86             gives :
 87             
 88             %begin c++%
 89             #include <iostream>
 90             int main()
 91             {
 92               std::cout << "Hello, world." << std::endl;
 93             }
 94             %end%
 95             
 96             _If you do not see a nice colorized piece of code above this, you should check if the plugin is well installed._
 97             
 98             You can also output numbered lines starting at 10 with this text:
 99             
100             <verbatim>%begin numbered:10 sh% 
101             #!/bin/sh
102             languages=`enscript --help-highlight | grep 'Name:' | cut -d ' ' -f 2`
103             for l in $languages; do
104             	 cat << EOF
105             	* $l
106 rizwank 1.1 EOF
107             done
108             %end% </verbatim>
109             which outputs:
110             
111             %begin numbered:10 sh%
112             #!/bin/sh
113             languages=`enscript --help-highlight | grep 'Name:' | cut -d ' ' -f 2`
114             for l in $languages; do
115             	 cat << EOF
116             	* $l
117             EOF
118             done
119             %end%
120             
121             ---+++ <nop>%TOPIC% Settings
122             
123             Plugin settings are stored as preferences variables. To reference
124             a plugin setting write ==%<nop>&lt;plugin&gt;_&lt;setting&gt;%==, i.e. ==%<nop>DEFAULTPLUGIN_SHORTDESCRIPTION%==
125             
126             	* One line description, is shown in the %TWIKIWEB%.TextFormattingRules topic:
127 rizwank 1.1 		* Set SHORTDESCRIPTION = This Plugin is used to emphasize the rendering of your twiki text according to several languages.
128             
129             	* Debug plugin: (See output in =data/debug.txt=)
130             		* Set DEBUG = 1
131             
132             ---+++ Plugin Installation Instructions
133             
134             	* Make sure you have GNU enscript 1.6.3 or above installed.
135             
136             	* Unzip the =SyntaxHighlighting.zip= package in your TWiki installation directory.
137             
138             	* If the installation is correct, you should see some highlighted text in this page.
139             
140             	* If you want support for additional languages (for customized or future enscript versions), you must edit the plugin file and add your languages to the languages array. _(Make sure that your =enscript= version supports the languages you add.)_
141             
142             ---+++ Known Bugs
143             
144             ---++++ Enscript oddities
145             
146             <verbatim>
147             %begin numbered sh% 
148 rizwank 1.1 # youpi
149             %end% 
150             </verbatim>
151             
152             gives
153             
154             %begin numbered sh%
155             # youpi
156             %end%
157             
158             Because =enscript= strangely adds an extra line (for closing its emphasizing markers) between the matched  &lt;pre&gt; &lt;/pre&gt; to its html output.
159             
160             Working around such a weird behavior is ... not planned.
161             
162             ---++++ WikiWords on last line
163             
164             <verbatim>%begin sh%
165             UnmatchedWikiword :)
166             MatchedWikiWord :(
167             %end%</verbatim>
168             
169 rizwank 1.1 gives
170             
171             %begin sh%
172             UnmatchedWikiword :)
173             MatchedWikiWord :(
174             %end%
175             
176             Adding a newline at the end of input stops TWiki in his greedy matching, but this workaround is not an acceptable solution. Feel free to find another one ....
177             ---+++ Plugin Info
178             
179             |  Plugin Author: | Main.NicolasTisserand, Main.NicolasBurrus, Perceval Anichini|
180             |  Plugin Version: | 12 Jul 2002 |
181             |  Change History: | 12 Jul 2002: Initial version |
182             |  CPAN Dependencies: | none |
183             |  Other Dependencies: | GNU enscript 1.6.3 |
184             |  Perl Version: | 5.0 |
185             |  Plugin Home: | http://www.lrde.epita.fr/cgi-bin/twiki/view/TWiki/SyntaxHighlightingPlugin |
186             |  Feedback: | Main.NicolasTisserand |
187             
188             __Related Topics:__ %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins, EmptyPlugin
189             
190 rizwank 1.1 -- Main.NicolasTisserand - 12 Jul 2002
191             

Rizwan Kassim
Powered by
ViewCVS 0.9.2