Fix #205: strip whitespace-only text nodes between codeline blocks
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user