[Repo Assist] fix: Markdown.ToMd preserves tight list formatting#1157
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Draft
[Repo Assist] fix: Markdown.ToMd preserves tight list formatting#1157github-actions[bot] wants to merge 2 commits intomainfrom
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
Tight lists (no blank lines between items in source) were converted to loose lists by ToMd because the list serialiser always emitted a blank line after every item. Root cause: the Unordered and Ordered ListBlock arms in formatParagraph unconditionally yielded "" after each item, regardless of whether the list was tight or loose. Fix: detect a tight list (every item is a single Span paragraph, as produced by the parser for simple/tight items) and suppress inter-item blank lines. A single trailing blank line is still emitted after the entire list so the document structure is preserved. Added three tests: - tight unordered list round-trip (no blank lines) - tight ordered list round-trip (no blank lines) - loose list round-trip (items with blank lines preserved) All 284 Markdown tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
25 tasks
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.
🤖 This is an automated pull request from Repo Assist.
Summary
Fixes a bug where
Markdown.ToMdconverts tight lists (no blank lines between items in the source) into loose lists during serialisation.Root Cause
In
MarkdownUtils.fs, theListBlock(Unordered, ...)andListBlock(Ordered, ...)arms offormatParagraphunconditionally emittedyield ""(a blank line) after every list item — regardless of whether the original list was tight or loose.The parser correctly distinguishes tight from loose via the paragraph type:
Span(...)(single paragraph per item)Paragraph(...)(may have multiple paragraphs per item)Fix
Detect a tight list by checking whether all items are single
Spanparagraphs. When the list is tight, suppress inter-item blank lines; emit one trailing blank line after the entire list only. This is consistent with how other block elements (headings, paragraphs, code blocks) are serialised.Tests Added
ToMd preserves tight unordered list without blank lines between itemsToMd preserves tight ordered list without blank lines between itemsToMd preserves loose list with blank lines between itemsTest Status
✅ Build: 0 warnings, 0 errors
✅ Tests: 284/284 Markdown tests pass (3 new tests added)