mirror of
https://github.com/boostorg/boostbook.git
synced 2025-05-09 15:03:57 +00:00
Initial support for highlighting jam code.
[SVN r77636]
This commit is contained in:
parent
dd17d84274
commit
aa80c5a141
@ -388,6 +388,12 @@
|
||||
</computeroutput>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="code[@lang='jam']" mode="annotation">
|
||||
<computeroutput>
|
||||
<xsl:apply-templates mode="annotation"/>
|
||||
</computeroutput>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="bold" mode="annotation">
|
||||
<emphasis role="bold">
|
||||
<xsl:apply-templates mode="annotation"/>
|
||||
|
@ -392,6 +392,12 @@ Error: XSL template 'link-or-anchor' called with invalid link-type '<xsl:value-o
|
||||
</computeroutput>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="code[@lang='jam']">
|
||||
<computeroutput>
|
||||
<xsl:apply-templates mode="highlight-jam"/>
|
||||
</computeroutput>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="bold">
|
||||
<emphasis role="bold">
|
||||
<xsl:apply-templates mode="annotation"/>
|
||||
|
@ -435,6 +435,75 @@
|
||||
</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="' ! != & && ( ) += : ; < <= = > >= ?= [ ] { | || } '"/>
|
||||
|
||||
<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(' 

	', 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(' 

	', 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: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 +550,14 @@
|
||||
<xsl:apply-templates mode="highlight"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*" mode="highlight-jam">
|
||||
<xsl:apply-templates 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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user