[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: RE: [docbook-apps] syntax highlighting with xslt2/pygments/jython/saxon
| -----Original Message-----
| From: Andreas Reuleaux
| java \
| -cp
|
"/opt/saxonhe/saxon9he.jar:/opt/dbk/xslt2/lib/docbook-xsl2-saxon.jar:/usr/sh
are/java/jython.jar" net.sf.saxon.Transform \
| -init:docbook.Initializer \
| -s:myfile.dbk \
| -xsl:fo-xslt2.xsl \
| -o:myfile.fo \
| -xi:on \
| -ext:on \
| use.extensions=1 \
| fop1.extensions=1
|
| OK, my toolchain still works, but no highlighting yet
At present, highlighting does not work for XSL-FO. There are two reasons as
far as I can tell:
1. The code for calling Pygments via Jython only handles (X)HTML output.
2. Pygments does not provide an XSL-FO formatter.
For XHTML, it took me a while to figure out how to make highlighting work
(Saxon HE on Windows XP). These points were particularly important:
1. Add role="pygments" to the <programlisting> element in the source XML.
2. Add
-Dpython.path=<path to Pygments install dir>
to the "java" command. This was necessary in order to avoid "ImportError: No
module named pygments".
3. Add the output generated from this snippet,
from pygments.formatters import HtmlFormatter
print HtmlFormatter().get_style_defs()
to a CSS file, and ensure that this file is referenced in the output (see
the docbook.css parameter).
Below is the contents of my Windows BAT file. I run it from the root
directory of the 2.0.2 relase downloaded from http://docbook.github.com/.
----------
java
-Dpython.path=c:/Java/jython2.5.2/Lib/site-packages/Pygments-1.4-py2.5.egg ^
-cp
c:/Java/saxon93/saxon9he.jar;./lib/docbook-xsl2-saxon.jar;c:/Java/jython2.5.
2/jython.jar ^
net.sf.saxon.Transform ^
-init:docbook.Initializer ^
-s:verbatim.xml ^
-xsl:./xslt/base/html/docbook.xsl ^
-o:verbatim.html ^
-xi:on ^
-ext:on ^
docbook.css=mydefault.css
----------
| * Also there is mention of some python.path setting in ~/.jython
| what does that look exactely (the path to the script maybe)?
As an alternative to '-Dpython.path=...' at the command line, you can add
python.path=<path to Pygments install dir>
to ~/.jython.
See http://wiki.python.org/jython/UserGuide#the-jython-registry
| * I use neither Saxon PE or EE, but saxonb and/or saxonhe
| so I guess I don't have to set
|
| <resources>
|
| <extensionFunction>org.docbook.extensions.xslt20.Cwd</extensi
onFunction>
|
| <extensionFunction>org.docbook.extensions.xslt20.ImageIntrins
ics</extensionFunction>
|
| <extensionFunction>org.docbook.extensions.xslt20.Pygmenter</e
xtensionFunction>
| </resources>
That's right, configuration files cannot be used with Saxon HE. See
http://www.saxonica.com/documentation/configuration/configuration-file.xml.
Mauritz
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]