This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.

Regards,
Oliver

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]