OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[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


which was a response to a mail thread:
  respectively for the beginning of the thread:  

i. e.  I'd like to

* use the xslt2 stylesheets

* have pygments do the syntax highlighting 
  (instead of xslthl as described e. g. in
  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 \

  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 

* 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
    >>> 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 \
  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 


Anyway, thanks in advance.


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]