summaryrefslogtreecommitdiff
path: root/tools/boostbook/xsl/source-highlight.xsl
diff options
context:
space:
mode:
Diffstat (limited to 'tools/boostbook/xsl/source-highlight.xsl')
-rw-r--r--tools/boostbook/xsl/source-highlight.xsl96
1 files changed, 96 insertions, 0 deletions
diff --git a/tools/boostbook/xsl/source-highlight.xsl b/tools/boostbook/xsl/source-highlight.xsl
index b3903e5ba6..4945e38ab1 100644
--- a/tools/boostbook/xsl/source-highlight.xsl
+++ b/tools/boostbook/xsl/source-highlight.xsl
@@ -435,6 +435,92 @@
</xsl:choose>
</xsl:template>
+ <!-- Jam syntax highlighting -->
+
+ <xsl:variable name="jam-keywords" select="' actions bind case class default else for if ignore in include local module on piecemeal quietly return rule switch together updated while '"/>
+ <xsl:variable name="jam-operators" select="' ! != &amp; &amp;&amp; ( ) += : ; &lt; &lt;= = &gt; &gt;= ?= [ ] { | || } '"/>
+
+ <xsl:template name="highlight-jam-word">
+ <xsl:param name="text"/>
+ <xsl:choose>
+ <xsl:when test="contains($jam-keywords, concat(' ', $text, ' '))">
+ <xsl:call-template name="highlight-keyword">
+ <xsl:with-param name="keyword" select="$text"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="contains($jam-operators, concat(' ', $text, ' '))">
+ <xsl:call-template name="highlight-special">
+ <xsl:with-param name="text" select="$text"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="jam-word-length">
+ <xsl:param name="text"/>
+ <xsl:param name="pos" select="1"/>
+ <xsl:choose>
+ <xsl:when test="string-length($text) + 1= $pos">
+ <xsl:value-of select="$pos - 1"/>
+ </xsl:when>
+ <xsl:when test="contains(' &#xA;&#xD;&#x9;', substring($text, $pos, 1))">
+ <xsl:value-of select="$pos - 1"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="jam-word-length">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="pos" select="$pos + 1"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="highlight-jam-text">
+ <xsl:param name="text"/>
+ <xsl:choose>
+ <xsl:when test="string-length($text) = 0"/>
+ <xsl:when test="contains(' &#xA;&#xD;&#x9;', substring($text, 1, 1))">
+ <xsl:value-of select="substring($text, 1, 1)"/>
+ <xsl:call-template name="highlight-jam-text">
+ <xsl:with-param name="text" select="substring($text, 2)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="substring($text, 1, 1) = '#'">
+ <xsl:choose>
+ <xsl:when test="contains($text, '&#xA;')">
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text" select="substring-before($text, '&#xA;')"/>
+ </xsl:call-template>
+ <xsl:call-template name="highlight-jam-text">
+ <xsl:with-param name="text" select="concat('&#xA;', substring-after($text, '&#xA;'))"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="highlight-comment">
+ <xsl:with-param name="text" select="$text"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="length">
+ <xsl:call-template name="jam-word-length">
+ <xsl:with-param name="text" select="$text"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:call-template name="highlight-jam-word">
+ <xsl:with-param name="text" select="substring($text, 1, $length)"/>
+ </xsl:call-template>
+ <xsl:call-template name="highlight-jam-text">
+ <xsl:with-param name="text" select="substring($text, $length + 1)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
<!-- Perform C++ syntax highlighting on the given text -->
<xsl:template name="highlight-text">
<xsl:param name="text" select="."/>
@@ -481,4 +567,14 @@
<xsl:apply-templates mode="highlight"/>
</xsl:template>
+ <xsl:template match="*" mode="highlight-jam">
+ <xsl:apply-templates select="." mode="annotation"/>
+ </xsl:template>
+
+ <xsl:template match="text()" mode="highlight-jam">
+ <xsl:call-template name="highlight-jam-text">
+ <xsl:with-param name="text" select="."/>
+ </xsl:call-template>
+ </xsl:template>
+
</xsl:stylesheet>