Repository navigation
fix(html): keep blank lines between blocks in indented HTML - #16
Merged
Merged
Conversation
Whitespace-only text between block elements stayed in block-context node
lists as Text(" "), so the renderer saw no adjacent blocks: headings,
paragraphs, lists and tables after the first ran together with a leading
space ("# A\n B"), breaking headings and tables as markdown. Normalize
block-context lists (body, blockquote, list item): drop whitespace-only
inline runs, wrap loose inline runs next to blocks in a Paragraph.
Golden fixtures had recorded the broken output and are regenerated.
Adds integration tests and a property test that indentation never
changes output.
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.
Requested by Михайло · project thread
What changed
HTML whose blocks are separated by source indentation (almost every real web page) now renders with blank lines between blocks and no leading spaces. Before, everything after the first block ran together with a leading space, which also stopped later headings and tables from being markdown at all.
The parser now normalizes block-context node lists (document body, blockquote, list item): whitespace-only inline runs between blocks are dropped, and loose inline text next to blocks becomes its own paragraph. Pure-inline content is untouched, so spaces between inline siblings survive.
Why
Found during the maintenance smoke test of
examples/basic.rs. The golden fixtures had recorded the broken output, so tests passed.Before / After
examples/basic.rsnow prints separated heading, paragraph, list and link paragraph. All 9 golden fixtures regenerated; each diff only adds blank lines and removes the leading space (reviewed one by one).Tests: 7 new integration tests (indented blocks, nested transparent containers, blockquote paragraphs, adjacent lists, loose text, inline-only unchanged) and a property test asserting indented and compact documents render identically. The property test fails on the old parser.
Known limitation, documented rather than fixed here: after an unclosed
<strong>, html5ever wraps the following paragraphs in it, so they render inside**(seemalformedfixture).Risk
Checklist
Generated by Claude Code