Skip to content

Commit 1b0a090

Browse files
committed
experimental ABNF highlighting extension for google prettify
1 parent b83ab8b commit 1b0a090

1 file changed

Lines changed: 34 additions & 6 deletions

File tree

rfc2629.xslt

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,9 @@
12761276
<xsl:value-of select="concat(' lang-',@x:lang)"/>
12771277
</xsl:if>
12781278
</xsl:if>
1279+
<xsl:if test="contains(@type,'abnf') and $prettyprint-class!=''">
1280+
<xsl:value-of select="concat(' ',$prettyprint-class,' lang-ietf_abnf')"/>
1281+
</xsl:if>
12791282
</xsl:variable>
12801283
<xsl:if test="normalize-space($v)!=''">
12811284
<xsl:attribute name="class"><xsl:value-of select="normalize-space($v)"/></xsl:attribute>
@@ -6128,8 +6131,33 @@ function anchorRewrite() {
61286131
window.addEventListener('hashchange', anchorRewrite);
61296132
window.addEventListener('DOMContentLoaded', anchorRewrite);
61306133
</script><xsl:if test="$prettyprint-script!=''">
6131-
<script src="{$prettyprint-script}"/></xsl:if>
6132-
</xsl:template>
6134+
<script src="{$prettyprint-script}"/></xsl:if><xsl:if test="contains($prettyprint-script,'prettify') and //artwork[contains(@type,'abnf')]">
6135+
<script><![CDATA[try {
6136+
PR['registerLangHandler'](
6137+
PR['createSimpleLexer'](
6138+
[
6139+
// comment
6140+
[PR['PR_COMMENT'], /^;[^\x00-\x1f]*/, null, ";"],
6141+
],
6142+
[
6143+
// string literals
6144+
[PR['PR_STRING'], /^(\%s|\%i)?"[^"\x00-\x1f]*"/, null],
6145+
// binary literals
6146+
[PR['PR_LITERAL'], /^\%b[01]+((-[01]+)|(\.[01]+)*)/, null],
6147+
// decimal literals
6148+
[PR['PR_LITERAL'], /^\%d[0-9]+((-[0-9]+)|(\.[0-9]+)*)/, null],
6149+
// hex literals
6150+
[PR['PR_LITERAL'], /^(\%x[A-Za-z0-9]+((-[A-Za-z0-9]+)|(\.[A-Za-z0-9]+)*))/, null],
6151+
// prose rule
6152+
[PR['PR_NOCODE'], /^<[^>\x00-\x1f]*>/, null],
6153+
// rule name
6154+
[PR['PR_TYPE'], /^([A-Za-z][A-Za-z0-9-]*)/, null],
6155+
[PR['PR_PUNCTUATION'], /^[=\(\)\*\/\[\]#]/, null],
6156+
]),
6157+
['ietf_abnf']);
6158+
} catch(e){}]]>
6159+
</script>
6160+
</xsl:if></xsl:template>
61336161

61346162
<!-- insert CSS style info -->
61356163

@@ -9883,11 +9911,11 @@ dd, li, p {
98839911
<xsl:variable name="gen">
98849912
<xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
98859913
<!-- when RCS keyword substitution in place, add version info -->
9886-
<xsl:if test="contains('$Revision: 1.1010 $',':')">
9887-
<xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.1010 $', 'Revision: '),'$','')),', ')" />
9914+
<xsl:if test="contains('$Revision: 1.1011 $',':')">
9915+
<xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.1011 $', 'Revision: '),'$','')),', ')" />
98889916
</xsl:if>
9889-
<xsl:if test="contains('$Date: 2018/05/08 18:34:23 $',':')">
9890-
<xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2018/05/08 18:34:23 $', 'Date: '),'$','')),', ')" />
9917+
<xsl:if test="contains('$Date: 2018/05/15 18:26:15 $',':')">
9918+
<xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2018/05/15 18:26:15 $', 'Date: '),'$','')),', ')" />
98919919
</xsl:if>
98929920
<xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))" />
98939921
</xsl:variable>

0 commit comments

Comments
 (0)