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
+5 -2
View File
@@ -166,8 +166,11 @@ func TestHighlightCode(t *testing.T) {
if plain != "<b>x</b>" {
t.Fatalf("plain escaping wrong: %q", plain)
}
// line count preserved (gutter alignment)
if got := len(splitLines(lang.HighlightCode("a\nb\nc", "go"))); got != 3 {
// #205: newline join preserved as the delimiter paste-lines.js splits on;
// per-line segments survive and the client joins with '' so no newline
// text node reaches the rendered DOM.
hl := lang.HighlightCode("a\nb\nc", "go")
if got := len(splitLines(hl)); got != 3 {
t.Fatalf("want 3 lines, got %d", got)
}
}