OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook-apps] Syntax coloring of programlisting

Hi Frans,

>I'm thinking about doing syntax highlightning of example code, typically found 
>in Docbook's programlisting[1] element. I've never seen this in Docbook, only 
>in web forums and such. Have anyone any experience with this, or is aware of 
>existing solutions? 
I've implemented something similar as XSLT extension function. The 
extension function takes two string parameters (the first parameter 
contains the plain code fragment, the second parameter defines its 
language) and returns an interim node-set representing the tokenized 
program. In a second step, the returned node-set can be processed 
further, e.g. transformed into formatted output.

My implementation is written for SAXON 6.5 and makes use of the free 
jEdit Syntax Package [1] which performs the actual tokenization. The 
implementation is just a few lines of Java code. I think a similar 
extension for other (Java-based) XSLT processors or syntax highlighting 
packages would be straight-forward. If you (or anyone else) is 
interested in it, I can publish the source.


[1] http://sourceforge.net/projects/jedit-syntax/

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]