At line 1 removed 3 lines |
!!Color Code Plugin |
By [RoyPhillips] |
|
At line 5 changed one line |
This plugin implements the {{[WikiPlugin|JSPWikiPlugin]}} interface, |
This plugin implements the {{~WikiPlugin}} interface, |
At line 20 changed one line |
classpath, for example, a [properties file|ColorCodePluginProperties], and use the properties in it to format the text |
classpath, for example, a [properties file|ColorCodePluginProperties], and use the properties in it to format the text. |
At line 19 added 13 lines |
---- |
|
*Could someone write here a short example where to actually put .properties file. Can't get this working. |
|
;:--Juhani, 26-Oct-2006 |
|
[Short Properties file example|ColorCodePlugin_egproperties] -- contents & location |
|
|
These properties define how (color, bold, italic) each element, such as keywords will be rendered, as well as listing the keywords and optionally, 'special' patterns in the text (see XML example below). Using the settings distributed, the example renders: |
|
[{Image src='colorcode_eg.bmp' width='99%;' }] |
|
At line 27 changed one line |
colorcode.special.pattern='<[/]?[a-z_-]+>' |
colorcode.special.tag.pattern='<[/]?[a-z_-]+>' |
At line 44 added one line |
[{Image src='colorcode_eg2.bmp' width='99%;' }] |
At line 35 changed 2 lines |
!Installing |
*Download the distribution jar into the local {{JSPWiki/WEB-INF/lib}} directory. |
!The Specials |
As well as the predefined categories of token, {{keyword, normal, string, number, symbol}}, the properties file may define any number of 'special' token classes. In the example above, the property {{colorcode.special.__tag__.pattern}} defined the pattern by which the special token class ''tag'' could be recognized. Otherwise 'normal' tokens that match this regular expression will be rendered according to the default special font properties, unless explictly specified by a matching {{colorcode.special.__tag__.font.color}} etc. definition. |
|
See [vm.properties] for an example of definining more than one class of special token. Notice that the ~StreamTokenizer has to be programmed to accept any non-alphabetic characters that form part of a special token, by including them in the {{tokenizer.ordinaryChar}} and {{tokenizer.wordChar}} properties. |
|
!Madness |
(sorry, that should have read __Installing__) |
*Download the [distribution jar|colorcode-plugin.jar] into the local {{JSPWiki/WEB-INF/lib}} directory. |
At line 57 added 6 lines |
!Building |
*Unpack the [source jar|colorcode-plugin-src.jar] into some convenient directory |
*Edit the {{build.properties}} file to set the local webserver path |
** E.g., {{webserver.dir=C:/Program Files/Apache Software Foundation/Tomcat 5.5}} |
*Run the ant task {{deploy}} |
|
At line 43 changed one line |
|[SyntaxTokenizer.java|]|A {{StreamTokenizer}} subclass that configures it's options from provided properties |
|[SyntaxTokenizer.java|]|A {{~StreamTokenizer}} subclass that configures it's options from provided properties |
At line 68 added one line |
|
At line 46 changed one line |
[Back|ContributedPlugins] |
[<< Back to Contributed Plugins|ContributedPlugins] |
|
|
---- |
|
do NOT forget to include the blank line between the syntax and your code! (wont work without)\\ |
are there any pre-defined .properties for other languages? |
|
--Max, 03-Oct-2006 |
|
Currently, the pre-defined .properties include: |
|[SQL|sql.properties]|SQL syntax highlighting (Oracle flavor) |
|[C/C++|c.properties]|C & C++ -- full C++ '98 keyword set |
|[Java|java.properties]|Works, but nowhere near as nice as [Java2HtmlPlugin] |
|[Velocity|vm.properties]|Velocity template file highlighing |
|
The XML example above could easily be converted to a properties file, as well. It's easy enough to create one for a different syntax - I have used inline definitions for emails, bash scripts, etc., that don't occur often enough for a formal properties file. |
|
--Roy, 03-Oct-2006 |
|
|
---- |
|
Fixed the special pattern matching to respect the '^' start-of-line anchor, making it easier to describe syntaxes such as Java {{.properties}} files: |
|
|
{{colorcode.area.bgcolor='white'}}\\ |
{{colorcode.normal.font.color='#0000C0'}}\\ |
{{colorcode.string.font.bold='true'}}\\ |
__{{colorcode.special.variable.pattern='^~[a-zA-Z0-9 /~\~\.-~]+'}}__\\ |
{{colorcode.special.variable.font.color='#800040'}}\\ |
{{colorcode.special.comment.pattern='^#~[ -~]+'}}\\ |
{{colorcode.special.comment.font.color='green'}}\\ |
{{colorcode.special.varsub.pattern='~\~\{~[0-9~]+~\~\}'}}\\ |
{{colorcode.special.varsub.font.color='black'}}\\ |
{{colorcode.special.varsub.font.bold='true'}}\\ |
{{tokenizer.ordinaryChar: '#,/,.,},{,.,0x20,0x2C'}}\\ |
{{tokenizer.wordChar: '#,/,.,},{,.,0x20,0x2C'}}\\ |
|
|
--Roy, 05-Oct-2006 |
|
---- |
|
Hi Roy... nice. And a rather compact little beastie, for anyone who care to look at the code and design of the plugin - |
|
One thing: some control over font-size would be nice... the HTML prologue/ epilogues currently come from hardcoded constants, and specify explicit sizes which would tend to override CSS? |
|
Later: |
We did manage to get past this - CSS style on 'code' tag, and use !important for the font-size specification. (thanks Phil Duhs for this tip) |
|
My preference for code snippets, is definitely *smaller* rather than *large print*. We run a development shop here not a, ahem, remedial reading course :) |
|
--Thomas Whitmore, 11-Jan-2007 |
---- |
Thanks for the comments, Thomas, I have added a new way of specifying markup styles in this plugin using spans/css classes (thanks to Damien French for the use case & testing). It works like this: |
|
Set the parameter {{spans}} to 'true' ({{ColorCodePlugin spans='true'}}), and it will insert spans with class set to the 2nd part of the property for the type of token, so if it's a symbol (property 'colorcode.symbol') it'll get class='symbol'. An external css can then define the appearance of that element. |
|
The built-in classes are : normal, keyword, symbol, string, number, comment, and 'specials' defined will get the user-defined part used as the class name, so "colorcode.special.email" will generate class="email" |
|
Does that help in your case? |
|
-- Roy, 16-Jan-2007 |
---- |
Has anyone done a properties file for python syntax? Thanks. |
|
-- Mariano, 27-Aug-2010 |
---- |
[<< Back to Contributed Plugins|ContributedPlugins] |