[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: syntax highlighting with xslt2/pygments/jython/saxon
I am trying to get syntax hightlighting working as described in http://norman.walsh.name/2011/08/31/xsltPygments which was a response to a mail thread: http://lists.oasis-open.org/archives/docbook-apps/201108/msg00132.html respectively for the beginning of the thread: http://lists.oasis-open.org/archives/docbook-apps/201108/msg00079.html i. e. I'd like to * use the xslt2 stylesheets * have pygments do the syntax highlighting (instead of xslthl as described e. g. in http://www.sagehill.net/docbookxsl/SyntaxHighlighting.html or http://xmlguru.cz/2006/07/docbook-syntax-highlighting) * by calling jython directly from saxonb/saxonhe (there are some instructions to use pygments with docbook at http://lunaryorn.de/articles/docbook_pygments.html but according to Norman's blog there should be an easier way to call jython directly from saxon) What I have now is this: * I can use the xslt2 stylesheets in my toolchain like this java \ -cp "/opt/saxonhe/saxon9he.jar:/opt/dbk/xslt2/lib/docbook-xsl2-saxon.jar" \ net.sf.saxon.Transform \ -s:myfile.dbk \ -xsl:fo-xslt2.xsl \ -o:myfile.fo \ -xi:on \ -ext:on \ use.extensions=1 \ fop1.extensions=1 fo-xslt2.xsl is my customization layer stylesheet which besides my customizations imports the main xslt2 stylesheet <xsl:import href="/opt/dbk/xslt2/xslt/base/fo/docbook.xsl" /> in this case for fo output, but it works equally well with html /opt/saxonhe ist just the path where I have put my saxonhe and my xslt2 stylesheets live in /opt/dbk * This works equally well for me if I use the (debian packaged) saxonb-xslt, in that case my classpath is "/usr/share/java/saxonb.jar:/opt/dbk/xslt2/lib/docbook-xsl2-saxon.jar" * Now I have installed jython as a debian package (I am on wheezy) # aptitude install jython * and installed pygments within jython by first getting easy_install working in jython # wet -nd http://peak.telecommunity.com/dist/ez_setup.py # jython ez_setup.py and then easy installing # /usr/share/jython/bin/easy_install pygments had to call it several times (don't know why), but it finally installed pygments, now I can call $ jython blahblah... >>> import pygments * Now I understand that I have to add jython.jar to my classpath above and have to initialize saxon (-init:docbook.Initializer) java \ -cp "/opt/saxonhe/saxon9he.jar:/opt/dbk/xslt2/lib/docbook-xsl2-saxon.jar:/usr/share/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 * I understand that saxon should call some jython script that contains at least something like from pygments.formatters import HtmlFormatter print HtmlFormatter().get_style_defs('.highlight') (or I guess something similar for fo) - but how do I tell saxonb/saxonhe to actually call this jython script? * Also there is mention of some python.path setting in ~/.jython what does that look exactely (the path to the script maybe)? * 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</extensionFunction> <extensionFunction>org.docbook.extensions.xslt20.ImageIntrinsics</extensionFunction> <extensionFunction>org.docbook.extensions.xslt20.Pygmenter</extensionFunction> </resources> Anyway, thanks in advance. -Andreas
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]