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

Commit 44a6f66

Browse files
author
mikesamuel
committed
another attempted fix for IE whitespace normalization
1 parent bb65f61 commit 44a6f66

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/prettify.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ function prettyPrintOne(s) {
12471247
// into pre blocks for some strange reason.
12481248
// IE seems to ignore the newlines unless they're proper windows style
12491249
// CRLFs.
1250-
html = html.replace(/(?:\r\n?)|\n/g, '\r\n').replace(/ /g, '  ');
1250+
//html = html.replace(/ /g, '  ');
12511251
}
12521252
out.push(html);
12531253
}
@@ -1315,7 +1315,14 @@ function prettyPrint() {
13151315
// push the prettified html back into the tag.
13161316
if (!isRawContent) {
13171317
// just replace the old html with the new
1318-
cs.innerHTML = newContent;
1318+
// To avoid newlines getting whacked by IE, use the workaround
1319+
// from http://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html
1320+
if ('insertAdjacentHTML' in cs) {
1321+
cs.innerHTML = '';
1322+
cs.insertAdjacentHTML(newContent);
1323+
} else {
1324+
cs.innerHTML = newContent;
1325+
}
13191326
} else {
13201327
// we need to change the tag to a <pre> since <xmp>s do not allow
13211328
// embedded tags such as the span tags used to attach styles to

0 commit comments

Comments
 (0)