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

Commit 553b83b

Browse files
bug 108:   not legal in XML
1 parent 8d591c6 commit 553b83b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGES.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ <h2>19 July 2010</h2>
120120
>102</a> courtesy jacobly.</li>
121121
<li>A variety of markup formatting fixes courtesy smain and thezbyg.</li>
122122
<li>Fixed copy and paste in IE[678].
123+
<li>Changed output to use <code>&amp;#160;</code> instead of
124+
<code>&amp;nbsp;</code> so that the output works when embedded in XML.
125+
Bug
126+
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=108"
127+
>108</a>.</li>
123128
</ul>
124129
</body>
125130
</html>

src/prettify.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,11 @@ window['_pr_isIE6'] = function () {
10961096
// on IE.
10971097
// Doing this on other browsers breaks lots of stuff since \r\n is
10981098
// treated as two newlines on Firefox.
1099-
? (isIE678 === 6 ? '&nbsp;\r\n' : '&nbsp;\r')
1099+
? (isIE678 === 6 ? '&#160;\r\n' : '&#160;\r')
11001100
// IE collapses multiple adjacent <br>s into 1 line break.
1101-
// Prefix every newline with '&nbsp;' to prevent such behavior.
1102-
: '&nbsp;<br />')
1101+
// Prefix every newline with '&#160;' to prevent such behavior.
1102+
// &nbsp; is the same as &#160; but works in XML as well as HTML.
1103+
: '&#160;<br />')
11031104
: '<br />');
11041105

11051106
// Look for a class like linenums or linenums:<n> where <n> is the 1-indexed
@@ -1152,7 +1153,7 @@ window['_pr_isIE6'] = function () {
11521153
tabExpander(sourceText.substring(outputIdx, sourceIdx)))
11531154
.replace(lastWasSpace
11541155
? startOrSpaceRe
1155-
: adjacentSpaceRe, '$1&nbsp;');
1156+
: adjacentSpaceRe, '$1&#160;');
11561157
// Keep track of whether we need to escape space at the beginning of the
11571158
// next chunk.
11581159
lastWasSpace = trailingSpaceRe.test(htmlChunk);

0 commit comments

Comments
 (0)