This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: [docbook-apps] Syntax coloring of programlisting
- From: Oliver Horn <oliver dot horn at gmx dot net>
- To: Frans Englich <frans dot englich at telia dot com>
- Cc: docbook-apps at lists dot oasis-open dot org
- Date: Tue, 09 Nov 2004 11:13:16 +0100
- Subject: Re: [docbook-apps] Syntax coloring of programlisting
- References: <200411081808.15912.frans.englich@telia.com>
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/