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

Commit a1c08ac

Browse files
fixed issue 20: IE6 collapses adjacent <br>s.
1 parent 48ce131 commit a1c08ac

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/prettify.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,10 @@ if (patternParts[2]) { console.log(uneval(patternParts)); }
10501050
// Keep track of whether we need to escape space at the beginning of the
10511051
// next chunk.
10521052
lastWasSpace = trailingSpaceRe.test(htmlChunk);
1053-
html.push(htmlChunk.replace(newlineRe, '<br />'));
1053+
// IE collapses multiple adjacient <br>s into 1 line break.
1054+
// Prefix every <br> with '&nbsp;' can prevent such IE's behavior.
1055+
var lineBreakHtml = window['_pr_isIE6']() ? '&nbsp;<br />' : '<br />';
1056+
html.push(htmlChunk.replace(newlineRe, lineBreakHtml));
10541057
outputIdx = sourceIdx;
10551058
}
10561059
}

tests/test_base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// get accurate timing.
22
// This file must be loaded after prettify.js for this to work.
33
PR_SHOULD_USE_CONTINUATION = false;
4-
if (!/[?&]testcopypaste\b/.test(location.search)) {
4+
if (!/\btestcopypaste\b/.test(location.fragment)) {
55
_pr_isIE6 = function() { return false; }; // Ensure consistent output.
66
}
77

0 commit comments

Comments
 (0)