docbook-apps

  • 1.  Different Colors for Different Programming Languages (Syntax Highlighting)?

    Posted 03-21-2013 07:30
    Hi,

    DocBook supports syntax highlighting in programlisting elements with
    the help of the language attribute and the highlighting stylesheets
    ({fo,*html*}/highlight.xsl and highlighting/common.xsl). This works for
    me.

    Now I'm wondering if I can go it a bit further. Usually, customizing
    the colors are done in xslthl mode. However, as it seems, I cannot get
    the original language attribute anymore. I would like to implement
    different colors for different programming languages.

    How can I do that? Is there a recommended procedure?

    Thanks!

    --
    Gruß/Regards,
    Thomas Schraitle



  • 2.  Re: [docbook-apps] Different Colors for Different Programming Languages (Syntax Highlighting)?

    Posted 03-21-2013 09:23
    Thomas, Publican [1] does this using the Kate HTML Syntax highlighting module.

    [1] https://fedorahosted.org/publican/

    - Josh


    ~ Kirtan is Life! ~
    Sent from my Mobile Device

    On 21/03/2013, at 5:30 PM, Thomas Schraitle <tom_schr@web.de> wrote:

    > Hi,
    >
    > DocBook supports syntax highlighting in programlisting elements with
    > the help of the language attribute and the highlighting stylesheets
    > ({fo,*html*}/highlight.xsl and highlighting/common.xsl). This works for
    > me.
    >
    > Now I'm wondering if I can go it a bit further. Usually, customizing
    > the colors are done in xslthl mode. However, as it seems, I cannot get
    > the original language attribute anymore. I would like to implement
    > different colors for different programming languages.
    >
    > How can I do that? Is there a recommended procedure?
    >
    > Thanks!
    >
    > --
    > Gruß/Regards,
    > Thomas Schraitle
    >
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >



  • 3.  Re: [docbook-apps] Different Colors for Different Programming Languages (Syntax Highlighting)?

    Posted 03-21-2013 09:26
    On 21.3.2013 8:30, Thomas Schraitle wrote:

    > How can I do that? Is there a recommended procedure?

    I'm not sure whether this is the easiest solution but you can override
    template apply-highlighting from highlighting/common.xsl in a way that
    for each language special mode will be invoked instead of just
    mode="xslthl", e.g.

    <xsl:when test="function-available('s6hl:highlight') and $language =
    'java'">
    <xsl:apply-templates select="s6hl:highlight($language,
    exsl:node-set($content), $highlight.xslthl.config)"
    mode="xslthl-java"/>
    </xsl:when>

    <xsl:when test="function-available('s6hl:highlight') and $language =
    'cpp'">
    <xsl:apply-templates select="s6hl:highlight($language,
    exsl:node-set($content), $highlight.xslthl.config)"
    mode="xslthl-cpp"/>
    </xsl:when>

    Then you need to copy all templates with mode="xslthl" and change mode
    to xslthl-java and xslthl-cpp and make appropriate changes.

    For future we might pass optional parameter called language to all
    templates in xslthl mode in order to for language in template for each
    kind of keyword. If you think this will work better for your scenario,
    please fill RFE.

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




  • 4.  Re: [docbook-apps] Different Colors for Different Programming Languages (Syntax Highlighting)?

    Posted 03-21-2013 10:19
    Hi,

    On Thu, 21 Mar 2013 10:25:46 +0100
    Jirka Kosek <jirka@kosek.cz> wrote:

    > [...]
    > I'm not sure whether this is the easiest solution but you can override
    > template apply-highlighting from highlighting/common.xsl in a way that
    > for each language special mode will be invoked instead of just
    > mode="xslthl", e.g.
    > [...]
    > Then you need to copy all templates with mode="xslthl" and change mode
    > to xslthl-java and xslthl-cpp and make appropriate changes.

    Ahh, right. Thanks for the hint!


    > For future we might pass optional parameter called language to all
    > templates in xslthl mode in order to for language in template for each
    > kind of keyword. If you think this will work better for your scenario,
    > please fill RFE.

    That would be a good idea. I've opened RFE#3608694.


    Thanks to Jirka and Joshua!


    --
    Gruß/Regards,
    Thomas Schraitle