docbook-apps

  • 1.  Syntax highlighting - setting colours

    Posted 04-16-2013 16:37
    Hello All,

    It seems that by default, keywords are bold. In addition to that,
    I want to make keywords blue and comments green. I copied the code
    to do it from
    http://www.sagehill.net/docbookxsl/SyntaxHighlighting.html,
    but it is not working. The text in the program listing is bold
    but black.

    My customisation layer looks like this:


     
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:fo="http://www.w3.org/1999/XSL/Format"
        xmlns:xslthl="http://xslthl.sf.net"
        exclude-result-prefixes="xslthl">

      <xsl:import href="file:///c:/mingw/local/share/docbook-xsl-ns-1.78.1/fo/docbook.xsl" />
      <xsl:import href="file:///c:/mingw/local/share/docbook-xsl-ns-1.78.1/fo/highlight.xsl" />
      <xsl:param name="highlight.source" select="1"/>

      <xsl:template match="xslthl:keyword">
      <fo:inline font-weight="bold" color="blue"><xsl:apply-templates/></fo:inline>
    </xsl:template>

    <xsl:template match="xslthl:comment">
      <fo:inline font-style="italic" color="green"><xsl:apply-templates/></fo:inline>
    </xsl:template>
     
    </xsl:stylesheet>


    The relevant section of my DocBook 5.0 "sub-document" (XIncluded in main
    document notes.xml) is

    <programlisting language="sql92">
    ...
    </programlisting>

    I transform notes.xml like this:

    xmllint --xinclude -o notesi.xml notes.xml

    %JAVA% -cp %CLASSPATH% -Dxslthl.config=/path/to/xslthl-config.xml com.icl.saxon.Stylesheet -o notes.fo notesi.xml notes.xsl

    %FOP% notes.fo notes.pdf

    What am I doing wrong?

    Regards,
    John Brown.


  • 2.  Re: [docbook-apps] Syntax highlighting - setting colours

    Posted 04-17-2013 07:17
    On 16.4.2013 18:36, John Brown wrote:

    > <xsl:template match="xslthl:keyword">

    You must have this templates in xslthl mode like

    <xsl:template match="xslthl:keyword" mode="xslthl">

    Jirka

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
    ------------------------------------------------------------------
    Bringing you XML Prague conference http://xmlprague.cz
    ------------------------------------------------------------------