docbook-apps

  • 1.  Color In Syntax Highlighting

    Posted 02-19-2017 23:42
    Hi,

    Thanks everyone for your patience with my previous questions on fonts and getting Saxon to work with syntax highlighting. I managed to get all of my changes into a set of customization files and make sure my actual DocBook and fop installations are stock. So now I'm looking closer at being able to use DocBook to describe source code.

    Right now the highlighting is xslthl-2.1.3, and DocBook is docbook-xsl-ns-1.79.1. Line numbering occurs, and syntax highlighting works, but it is limited to bold, italic, or normal text...there is no color involved. I see many PDF or web pages which have beautiful colorized syntax highlighting produced via DocBook (or fop I guess I should say). Is there some additional downloads for including color and not just grayscale? Or perhaps there is a config file to enable color (xslthl-config.xml and related files don't seem to mention color anywhere)?

    Thanks!


  • 2.  Re: [docbook-apps] Color In Syntax Highlighting

    Posted 02-20-2017 07:26
    Hi,

    There is a "highlight.xsl" specific for the XSL-FO PDF publishing which
    matches various syntax highlight range elements and adds bold or italic
    styling to them like:

    > <xsl:template match='xslthl:value' mode="xslthl">
    > <fo:inline font-weight="bold"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>

    For example we have replaced the default PDF styling templates for our
    Oxygen XML user's manual with templates applying color styling:

    >
    > <xsl:template match='xslthl:keyword' mode="xslthl">
    > <fo:inline font-weight="bold" color="#7f0055"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    >
    > <xsl:template match='xslthl:string' mode="xslthl">
    > <fo:inline font-weight="bold" font-style="italic" color="#2a00ff"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    >
    > <xsl:template match='xslthl:comment' mode="xslthl">
    > <fo:inline font-style="italic" color="#006400"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    >
    > <xsl:template match='xslthl:tag' mode="xslthl">
    > <fo:inline font-weight="bold" color="#000096"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    > <xsl:template match='xslthl:xslt' mode="xslthl">
    > <fo:inline font-weight="bold" color="#0092E6"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    > <xsl:template match='xslthl:attribute' mode="xslthl">
    > <fo:inline font-weight="bold" color="#ff7935"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    >
    > <xsl:template match='xslthl:value' mode="xslthl">
    > <fo:inline font-weight="bold" color="#993300" ><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    >
    > <xsl:template match='xslthl:number' mode="xslthl">
    > <xsl:apply-templates mode="xslthl"/>
    > </xsl:template>
    >
    > <xsl:template match='xslthl:annotation' mode="xslthl">
    > <fo:inline color="gray"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    >
    > <xsl:template match='xslthl:directive' mode="xslthl">
    > <fo:inline color="#8b26c9"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    >
    >
    > <xsl:template match='xslthl:doccomment' mode="xslthl">
    > <fo:inline font-weight="bold" color="#3f5fbf"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>
    >
    > <xsl:template match='xslthl:doctype' mode="xslthl">
    > <fo:inline font-weight="bold" color="#0000ff"><xsl:apply-templates mode="xslthl"/></fo:inline>
    > </xsl:template>

    Regards,
    Radu

    Radu Coravu
    <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    http://www.oxygenxml.com

    On 2/20/2017 1:42 AM, stimits@comcast.net wrote:
    > Hi,
    >
    > Thanks everyone for your patience with my previous questions on fonts
    > and getting Saxon to work with syntax highlighting. I managed to get all
    > of my changes into a set of customization files and make sure my actual
    > DocBook and fop installations are stock. So now I'm looking closer at
    > being able to use DocBook to describe source code.
    >
    > Right now the highlighting is xslthl-2.1.3, and DocBook is
    > docbook-xsl-ns-1.79.1. Line numbering occurs, and syntax highlighting
    > works, but it is limited to bold, italic, or normal text...there is no
    > color involved. I see many PDF or web pages which have beautiful
    > colorized syntax highlighting produced via DocBook (or fop I guess I
    > should say). Is there some additional downloads for including color and
    > not just grayscale? Or perhaps there is a config file to enable color
    > (xslthl-config.xml and related files don't seem to mention color anywhere)?
    >
    > Thanks!





  • 3.  Re: [docbook-apps] Color In Syntax Highlighting

    Posted 02-20-2017 18:09
    That makes beautiful source code! Thank you!