A possible requirement for your <codeblock>
elements could be to alternate the background color on each line. Some advantages of this
technique is that you can clearly see when text from the <codeblock> is
wrapped.
This effect can be done by altering the HTML5 output, creating a
div for each line from the code block, then styling them.
To add this functionality using an Oxygen Publishing Template, follow these steps:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0">
<xsl:template match="*[contains(@class, ' pr-d/codeblock ')]">
<xsl:variable name="nm">
<xsl:next-match/>
</xsl:variable>
<xsl:apply-templates select="$nm" mode="zebra"/>
</xsl:template>
<xsl:template match="node() | @*" mode="zebra">
<xsl:copy>
<xsl:apply-templates select="node() | @*" mode="#current"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[contains(@class, ' pr-d/codeblock ')]" mode="zebra">
<xsl:element name="{name()}">
<xsl:copy-of select="@*"/>
<xsl:attribute name="class" select="concat(@class, ' zebra')"/>
<xsl:analyze-string regex="\n" select=".">
<xsl:matching-substring/>
<xsl:non-matching-substring>
<div>
<xsl:value-of select="."/>
</div>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:element>
</xsl:template>
</xsl:stylesheet>com.oxygenxml.pdf.css.xsl.merged2html5 XSLT extension
point:<publishing-template>
...
<pdf>
...
<xslt>
<extension
id="com.oxygenxml.pdf.css.xsl.merged2html5"
file="xslt/merged2html5Extension.xsl"/>
</xslt><codeblock> structure. For
example:.zebra {
padding: 0;
}
.zebra > *:nth-of-type(odd) {
background-color: lightgray;
}resources
element:<publishing-template>
...
<pdf>
...
<resources>
<css file="css/custom.css"/>
</resources>