blob: 4ae5e437a070e36ef9805359a5fb6395d18061d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:str="http://exslt.org/strings"
xmlns:exslt="http://exslt.org/common"
extension-element-prefixes="str exslt xsl"
exclude-result-prefixes="str exslt xsl"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template name="lang.highlight.sgml.subtokenate">
<xsl:param name="data"/>
<xsl:choose>
<xsl:when test="starts-with($data, '<') or substring($data, string-length($data)) = '>'">
<span class="Identifier"><xsl:value-of select="$data"/></span>
</xsl:when>
<!-- No match return -->
<xsl:otherwise>
<xsl:value-of select="$data"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="lang.highlight.sgml.tokenate">
<xsl:param name="data"/>
<!-- Only tokenize spaces, this way we preserve tabs. -->
<xsl:variable name="tokenizedData" select="str:tokenize_plasmaroo($data, '" 	<>')"/>
<!-- Scan for quotes... -->
<xsl:for-each select="exslt:node-set($tokenizedData)">
<xsl:variable name="myPos" select="position()"/>
<xsl:variable name="quotePos" select="count(../*[@delimiter='"' and position() < $myPos])"/>
<xsl:variable name="tagPosOpen" select="count(../*[@delimiter='<' and position() < $myPos])"/>
<xsl:variable name="tagPosClosed" select="count(../*[@delimiter='>' and position() < $myPos])"/>
<xsl:choose>
<!-- Highlight a quote -->
<xsl:when test=". = '"'">
<span class="Statement">"</span>
</xsl:when>
<!-- If we're inside quotes stop here -->
<xsl:when test="$quotePos mod 2 != 0">
<span class="Constant">
<xsl:value-of select="."/>
</span>
</xsl:when>
<xsl:when test="contains(., '=') and $tagPosOpen != $tagPosClosed">
<span class="Identifier"><xsl:value-of select="substring-before(., '=')"/></span>
<span class="Constant">=</span>
<xsl:call-template name="lang.highlight.sgml.subtokenate">
<xsl:with-param name="data" select="substring-after(., '=')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$tagPosOpen != $tagPosClosed">
<span class="Identifier"><xsl:value-of select="."/></span>
</xsl:when>
<!-- No match return -->
<xsl:otherwise>
<xsl:call-template name="lang.highlight.sgml.subtokenate">
<xsl:with-param name="data" select="."/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|