Fix #205: guard splitLines() when server HTML has no newlines so renumber runs
CI / test (pull_request) Successful in 44s
CI / docker (pull_request) Skipped

This commit is contained in:
fen
2026-09-10 13:12:52 -05:00
parent 348f792c73
commit 555e5b30be
+7
View File
@@ -20,6 +20,13 @@
// box per line, which would shift every following number down one row (#167). // box per line, which would shift every following number down one row (#167).
function splitLines() { function splitLines() {
var html = body.innerHTML; var html = body.innerHTML;
if (html.indexOf('\n') < 0) {
// No newline text nodes to split on (already joined in the server
// template or stripped upstream): blocks are already adjacent, so
// leave the DOM alone. Splitting here would clone the whole markup
// into one block and leave renumber() reading stale nodes (#205).
return;
}
var parts = html.split('\n'); var parts = html.split('\n');
var out = []; var out = [];
for (var i = 0; i < parts.length; i++) { for (var i = 0; i < parts.length; i++) {