Fix MarkdownRenderer blockquote child spacing - #472
Open
deepakganesh78 wants to merge 1 commit into
Open
Conversation
Avoid inserting top-level blank separators between adjacent child blocks when rendering Markdown block quotes, while preserving explicit blank_line tokens inside the quote. Fixes lepture#368 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #472 +/- ##
==========================================
+ Coverage 91.18% 91.21% +0.02%
==========================================
Files 36 36
Lines 3631 3642 +11
Branches 677 679 +2
==========================================
+ Hits 3311 3322 +11
Misses 193 193
Partials 127 127 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 #368
Reproduction
On current
main, reformatting a block quote with adjacent child blocks inserts an extra quoted blank line:Before this change the result was
'> #### Lorem\n> \n> Ipsum\n'.Root cause
MarkdownRenderer.block_quote()rendered its child tokens as top-level Markdown before adding quote markers. Top-level block renderers intentionally end blocks with blank separators, so adjacent child blocks inside the same quote gained an extra>line even when the parsed quote AST did not contain ablank_linetoken.Fix
Render block quote children token-by-token and collapse only the structural separator between adjacent non-blank child tokens before applying the quote prefix. Explicit
blank_linetokens are preserved, so quoted paragraph breaks continue to render with a quoted blank line.Compatibility
This only changes MarkdownRenderer output for adjacent child blocks inside block quotes. HTML rendering and explicit blank lines within block quotes are unchanged.
Validation
python -m pytest tests\test_renderers.py::TestMarkdownRendererRoundTrip::test_block_quote_adjacent_child_blocks -q-> 1 passed'> #### Lorem\n> \n> Ipsum\n' != '> #### Lorem\n> Ipsum\n'python -m pytest-> 765 passedpython -m ruff check .-> All checks passedpython -m mypy-> Success: no issues found in 38 source files