Skip to content
This repository was archived by the owner on Oct 28, 2022. It is now read-only.

Commit 390bdd1

Browse files
committed
Safer text formatting
1 parent 256b1e7 commit 390bdd1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

javascript.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,15 @@ sf.format = function() {
223223
comments[c].style.marginLeft = "3px";
224224
}
225225

226-
comments[c].innerHTML = sf.parse(comments[c].innerHTML);
226+
// Go through all the text child nodes and replace them with a span
227+
// element.
228+
for (var i = 0; i < comments[c].childNodes.length; i++) {
229+
if (comments[c].childNodes[i].nodeName == "#text") {
230+
var p = document.createElement("span");
231+
p.innerHTML = " " + sf.parse(comments[c].childNodes[i].data);
232+
comments[c].childNodes[i].replaceWith(p);
233+
}
234+
}
227235
}
228236
}
229237

0 commit comments

Comments
 (0)