Customizing Syntax Highlighting colors

22 views
Skip to first unread message

Jean-Marc Meessen

unread,
Feb 13, 2014, 5:18:58 AM2/13/14
to docbkx-to...@googlegroups.com
Hello,

I have a hard time to customise the colours used when rendering the syntax highlighting.

I used the technique described at http://www.sagehill.net/docbookxsl/SyntaxHighlighting.html to adapt my customisation layer but it doesn't work. I would like to have the comments in italic green.

The above mentioned article, talks about a xslthl.config file but I don't see where to set it up in docbkx and if it will solve my problem.

Jmm

Mimil Mimil

unread,
Feb 13, 2014, 5:28:40 PM2/13/14
to docbkx-to...@googlegroups.com
I think you could have a look at this sample:

<!--
         The later versions of the DocBook stylesheets support syntax
         highlighting. In order to use it, add a language attribute to
         the DocBook element containing your sources, and set it to
         the language of the sources within that element. In your
         pom.xml configuration, set highlightSource to true and import
         highlight.xsl in your customization layer in order to enable
         highlighting support. (&lt;xsl:import href="urn:docbkx:stylesheet/highlight.xsl"/&gt;)
    -->
    <profile>
      <id>docbkx.highlighter</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.agilejava.docbkx</groupId>
            <artifactId>docbkx-maven-plugin</artifactId>
            <version>${project.version}</version>
            <dependencies>
              <dependency>
                  <groupId>net.sf.xslthl</groupId>
                  <artifactId>xslthl</artifactId>
                  <version>2.0.1</version>
                  <scope>runtime</scope>
              </dependency>
              <dependency>
                  <groupId>net.sf.offo</groupId>
                  <artifactId>fop-hyph</artifactId>
                  <version>1.2</version>
                  <scope>runtime</scope>
              </dependency>
            </dependencies>
            <configuration>
              <highlightSource>1</highlightSource>
              <!--highlightXslthlConfig>/file/.../xslthl-config.xml</highlightXslthlConfig-->
              <foCustomization>src/docbkx/docbook-fo.xsl</foCustomization>
              <hyphenate>true</hyphenate>
              <hyphenateVerbatim>true</hyphenateVerbatim>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <properties>
        <example.title>Syntax Highlighting</example.title>
      </properties>
    </profile>

Tell me if it still does not work.

Regards,
Cedric


--
You received this message because you are subscribed to the Google Groups "Docbkx Tools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to docbkx-tools-us...@googlegroups.com.
To post to this group, send email to docbkx-to...@googlegroups.com.
Visit this group at http://groups.google.com/group/docbkx-tools-users.
For more options, visit https://groups.google.com/groups/opt_out.

Jean-Marc Meessen

unread,
Feb 14, 2014, 3:40:24 PM2/14/14
to docbkx-to...@googlegroups.com
Hello Cedric,

Yes I have been using this method (not forgetting to load include the style sheet in the foCustomization). Highlighting is working: keywords are bold and comments are italic.

What I want to achieve is changing the color of the comments in green (so that they stand out of the code). I tried using the sample in the above mentioned site.

Jmm

Mimil Mimil

unread,
Feb 25, 2014, 3:46:13 PM2/25/14
to docbkx-to...@googlegroups.com
Hi,

I just tried, in fact you have to add your docbook highlighting into you customization layer, not in the xslthl-config.xml which is used to add new highlighters to support new programming languages ...

I added this to my layer and it is coloring in blue:

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

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

Regards,
Cedric

PS: I will update the documentation
Reply all
Reply to author
Forward
0 new messages