Fix #205: strip whitespace-only text nodes between codeline blocks
CI / test (pull_request) Successful in 43s
CI / docker (pull_request) Skipped

paste-lines.js rebuilt the codebody with innerHTML but relied on the
server-side '\n' delimiters disappearing between the per-line blocks.
Under white-space: pre any whitespace-only text node that survives
(cached HTML, template drift) renders as a phantom row and drifts the
gutter numbers off their lines. splitLines() now strips whitespace-only
text nodes after rebuilding, keeping renumber() geometry intact.
This commit is contained in:
fen
2026-09-10 13:12:12 -05:00
parent 672288e60b
commit 5034f156ee
3 changed files with 19 additions and 3 deletions
+4
View File
@@ -146,5 +146,9 @@ func HighlightCode(content, langID string) string {
for i, line := range lines {
out[i] = highlightLine(line, h, langID)
}
// Note: lines are joined with "\n" on purpose — paste-lines.js splits on
// the newline to build its per-line .codeline blocks, then joins those
// with "" and strips whitespace-only text nodes (#205), so no newline
// text node ever reaches the rendered DOM.
return strings.Join(out, "\n")
}