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:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user