Repository navigation
Conversation
Pretty-printed HTML puts a newline between block elements, and that newline is its own text node. It was collapsed to a single space and appended, so "<p>one</p>\n<p>two</p>" converted to "one\n\n two" with a stray leading space on the second block. The same whitespace-only node between inline elements is a real word separator, so it cannot simply be discarded. A block always ends by appending a newline, which makes the buffer a reliable signal: if the output so far ends with a newline the whitespace is layout and is dropped, otherwise it is kept as a single space. Fixes #33 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b721ad5f-9add-4f55-b9c8-7e6d7b0fb3e7
trsdn
changed the base branch from
fix/34-code-block-language
to
test/23-converter-tests
August 28, 2026 20:58
trsdn
changed the base branch from
test/23-converter-tests
to
fix/34-code-block-language
August 28, 2026 20:59
Owner
Author
|
Superseded by #53. These commits are already contained in that branch, so this PR would merge nothing on its own. Collapsing the stacked converter PRs into one avoids the base-rewriting problem that made the stack unmergeable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #33
Pretty-printed HTML puts a newline between block elements, and that newline is its own text node. It was collapsed to a single space and appended, so
<p>one</p>\n<p>two</p>converted toone\n\n twowith a stray leading space on the second block. Anything that pastes formatted HTML hits this, since almost every source indents its markup.The part that makes this non-trivial
The obvious fix, discarding whitespace-only text nodes, is wrong: between inline elements the very same node is a real word separator, so
<em>a</em> <em>b</em>would become*a**b*.The distinguishing signal turns out to already be in the output buffer. Every block element finishes by appending a newline, so if the buffer ends with a newline the whitespace is layout and can be dropped; otherwise it is inline and is kept as a single space. That also handles leading whitespace at the very start of a document, where the buffer is still empty.
Verification
Full suite: 86 passed, 0 failed, 1 skipped. The remaining skip is #32, which is still open. The inline-spacing cases are covered by the existing tests, which is what pinned down that the naive fix would have regressed them.
Base branch
Stacked on
fix/34-code-block-language(PR #51), which is itself stacked on the test project in PR #41. Merge order is #41, then #51, then this.