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

Commit fc98010

Browse files
author
mikesamuel
committed
Backed out attempted newline fixes for IE and fixed space issues.
1 parent 2c3abab commit fc98010

2 files changed

Lines changed: 241 additions & 251 deletions

File tree

src/prettify.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,9 +1245,12 @@ function prettyPrintOne(s) {
12451245
if (null != t.style) {
12461246
// This interacts badly with some wikis which introduces paragraph tags
12471247
// into pre blocks for some strange reason.
1248-
// IE seems to ignore the newlines unless they're proper windows style
1249-
// CRLFs.
1250-
//html = html.replace(/ /g, '  ');
1248+
// It's necessary for IE though which seems to lose the preformattedness
1249+
// of <pre> tags when their innerHTML is assigned.
1250+
// http://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html
1251+
html = html
1252+
.replace(/(\r\n?|\n| ) /g, '$1&nbsp;')
1253+
.replace(/\r\n?|\n/g, '<br>');
12511254
}
12521255
out.push(html);
12531256
}
@@ -1315,14 +1318,7 @@ function prettyPrint() {
13151318
// push the prettified html back into the tag.
13161319
if (!isRawContent) {
13171320
// just replace the old html with the new
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('afterBegin', newContent);
1323-
} else {
1324-
cs.innerHTML = newContent;
1325-
}
1321+
cs.innerHTML = newContent;
13261322
} else {
13271323
// we need to change the tag to a <pre> since <xmp>s do not allow
13281324
// embedded tags such as the span tags used to attach styles to

0 commit comments

Comments
 (0)