fix: preserve loose list spacing in MarkdownRenderer#272
Open
gaoflow wants to merge 1 commit into
Open
Conversation
render_list() joined items with "" regardless of element.tight, so a loose list (items separated by blank lines, tight=False) was re-emitted as a tight list. This changes the HTML output: tight items render as plain text while loose items wrap each item in <p> tags. Fix: join rendered items with "\n" when tight is False so the blank line between items is preserved.
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.
Problem
MarkdownRenderer.render_list()always joins rendered list items with"", ignoring theelement.tightattribute. This means a looselist (items separated by blank lines,
tight=False) is re-emitted asa tight list, silently changing the document's semantics.
The difference matters: a tight list renders list content as bare text,
while a loose list wraps each item in
<p>tags.Converting the re-rendered output back to HTML gives different HTML:
- item1\n\n- item2\n(loose)<ul><li><p>item1</p></li><li><p>item2</p></li></ul>- item1\n- item2\n(tight)<ul><li>item1</li><li>item2</li></ul>Fix
When
element.tightisFalse, join the rendered items with"\n"(a blank line) instead of
"".Tests
Added
test_markdown_renderer_loose_listcovering loose unorderedlists, 3-item loose lists, and loose ordered lists — verifying both
exact text round-trip and HTML semantic equivalence.
All 1397 tests pass.