Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit 78b5e48

Browse files
author
mikesamuel
committed
Fixed issue 19: XML tag names can contain 19
1 parent 565f704 commit 78b5e48

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

src/prettify.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ function PR_extractTags(s) {
391391
} else if (pr_brPrefix.test(match)) {
392392
// <br> tags are lexically significant so convert them to text.
393393
// This is undone later.
394-
// <br> tags are lexically significant
394+
// <br> tags are lexically significant
395395
sourceBuf.push('\n');
396396
sourceBufLen += 1;
397397
} else {
@@ -534,7 +534,7 @@ var PR_C_STYLE_LITERAL_IDENTIFIER_PUNC_RECOGNIZER = PR_createSimpleLexer([], [
534534
[PR_PUNCTUATION, /^[^\s\w\.$@]+/, null]
535535
// Fallback will handle decimal points not adjacent to a digit
536536
]);
537-
537+
538538
/** splits plain text tokens into more specific tokens, and then tries to
539539
* recognize keywords, and types.
540540
* @private
@@ -618,10 +618,10 @@ var PR_TAG_LEXER = PR_createSimpleLexer([
618618
[PR_ATTRIB_VALUE, /^\"[^\"]*(?:\"|$)/, null, '"'],
619619
[PR_PUNCTUATION, /^[<>\/=]+/, null, '<>/=']
620620
], [
621-
[PR_TAG, /^[\w-]+/, /^</],
622-
[PR_ATTRIB_VALUE, /^[\w-]+/, /^=/],
623-
[PR_ATTRIB_NAME, /^[\w-]+/, null],
624-
[PR_PLAIN, /^\s+/, null, ' \r\n']
621+
[PR_TAG, /^[\w:-]+/, /^</],
622+
[PR_ATTRIB_VALUE, /^[\w-]+/, /^=/],
623+
[PR_ATTRIB_NAME, /^[\w:-]+/, null],
624+
[PR_PLAIN, /^\s+/, null, ' \t\r\n']
625625
]);
626626
/** split tags attributes and their values out from the tag name, and
627627
* recursively lex source chunks.
@@ -737,10 +737,10 @@ function PR_decorateSource(sourceCode) {
737737
// contain stuff that looks like other tokens, so we want to mark those early
738738
// so we don't recurse into them.
739739
var decorations = PR_splitStringAndCommentTokens(sourceCode);
740-
740+
741741
// Split non comment|string tokens on whitespace and word boundaries
742742
decorations = PR_splitNonStringNonCommentTokens(sourceCode, decorations);
743-
743+
744744
return decorations;
745745
}
746746

@@ -856,7 +856,7 @@ function PR_recombineTagsAndDecorations(
856856
// Close the current decoration
857857
html.push('</span>');
858858
openDecoration = null;
859-
}
859+
}
860860
html.push(extractedTags[tagPos + 1]);
861861
tagPos += 2;
862862
} else if (decPos < decorations.length) {

tests/prettify_test.html

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ <h1>XHTML</h1>
366366
</pre>
367367

368368
<h1>PHP</h1>
369-
<pre class="prettyprint" id ="PHP">
369+
<pre class="prettyprint" id="PHP">
370370
&lt;html>
371371
&lt;head>
372372
&lt;title>&lt;?= 'Fibonacci numbers' ?>&lt;/title>
@@ -394,6 +394,17 @@ <h1>PHP</h1>
394394
&lt;/html>
395395
</pre>
396396

397+
<h1>XSL (Issue 19)</h1>
398+
<pre class="prettyprint" id="xsl">
399+
&lt;!-- Test elements and attributes with namespaces --&gt;
400+
401+
&lt;xsl:stylesheet xml:lang="en"&gt;
402+
&lt;xsl:template match="."&gt;
403+
&lt;xsl:text&gt;Hello World&lt;/xsl:text&gt;
404+
&lt;/xsl:template&gt;
405+
&lt;/xsl:stylesheet&gt;
406+
</pre>
407+
397408
<h1>Whitespace</h1>
398409
<pre class=prettyprint id="whitespace"></pre>
399410

@@ -902,11 +913,27 @@ <h1>Bug 14b - comments not ignored</h1>
902913
'`PUN(`END`LIT10`END`PUN)`END`PLN `END`PUN?&gt;`END`PLN<br>' +
903914
'&nbsp; `END`PUN&lt;/`END`TAGbody`END`PUN&gt;`END`PLN<br>' +
904915
'`END`PUN&lt;/`END`TAGhtml`END`PUN&gt;`END'),
916+
xsl: (
917+
'`COM&lt;!-- Test elements and attributes with namespaces --&gt;' +
918+
'`END`PLN<br>' +
919+
'<br>' +
920+
'`END`PUN&lt;`END`TAGxsl:stylesheet`END`PLN `END`ATNxml:lang`END' +
921+
'`PUN=`END`ATV"en"`END`PUN&gt;`END`PLN<br>' +
922+
'&nbsp; `END`PUN&lt;`END`TAGxsl:template`END' +
923+
'`PLN `END`ATNmatch`END`PUN=`END`ATV"."`END' +
924+
'`PUN&gt;`END`PLN<br>' +
925+
'&nbsp; &nbsp; `END`PUN&lt;`END`TAGxsl:text`END`PUN&gt;`END' +
926+
'`PLNHello World`END' +
927+
'`PUN&lt;/`END`TAGxsl:text`END`PUN&gt;`END`PLN<br>' +
928+
'&nbsp; `END`PUN&lt;/`END`TAGxsl:template`END`PUN&gt;`END`PLN<br>' +
929+
'`END`PUN&lt;/`END`TAGxsl:stylesheet`END`PUN&gt;`END'
930+
),
905931
whitespace: '',
906932
misc1: '`COM// ends with line comment token`END`PLN<br>' +
907933
'`END`COM//`END',
908934
issue4: (
909-
'`PUN&lt;`END`TAGscript`END`PLN `END`ATNtype`END`PUN=`END`ATV"text/javascript"`END' +
935+
'`PUN&lt;`END`TAGscript`END`PLN `END' +
936+
'`ATNtype`END`PUN=`END`ATV"text/javascript"`END' +
910937
'`PUN&gt;`END`PLN<br>' +
911938
'&nbsp; &nbsp;var savedTarget=null' +
912939
'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' +

0 commit comments

Comments
 (0)