Tuesday, February 23, 2010

Syntax Highlighting in DocBook

I am continuing to use DocBook, and I discovered that you can have syntax highlighting within your element.

* http://www.sagehill.net/docbookxsl/SyntaxHighlighting.html

Well technically you can only do that using a customization layer:

* http://www.sagehill.net/docbookxsl/CustomMethods.html

Then set the appropriate params:

* http://docbook.sourceforge.net/release/xsl/current/doc/fo/highlight.source.html

You also need to set this one:

* http://docbook.sourceforge.net/release/xsl/current/doc/html/highlight.xslthl.config.html

I had to use the following syntax on my linux box:


$ java -classpath /usr/share/java/saxon.jar:/home/mathieu/Software/xslthl/xslthl-2.0.1.jar -Dxslthl.config="file:////home/mathieu/Software/xslthl/highlighters/xslthl-config.xml" com.icl.saxon.StyleSheet -o myfile.html input.xml myhtml.xsl
Because I could not figure out how to use highlight.xslthl.config. After struggling for a bit:

* http://www.mail-archive.com/docbook-apps@lists.oasis-open.org/msg13791.html

One simply needs to use the URL notation for file address, in this case:


<xsl:param name="highlight.xslthl.config">file:////home/mathieu/Software/xslthl/highlighters/xslthl-config.xml</xsl:param>

I then started to play with xslthl, and make a cmake DocBook syntax highlighting file:

* http://gdcm.svn.sf.net/viewvc/gdcm/Sandbox/debian-med/xslthl/cmake-hl.xml?view=markup

Reference:
* http://sourceforge.net/apps/mediawiki/xslthl/index.php?title=Syntax_Highlighters

No comments: