Repository navigation
fix: end every writer block with exactly one newline - #111
Merged
Merged
Conversation
String-equality tests pin the exact bytes but cannot tell whether those bytes parse as intended. Add test helpers that parse writer output with pulldown-cmark (with the definition list extension) and, when available, Pandoc, and render a normalized block tree: which blocks exist, how they nest, and whether lists are tight or loose. Pin the current trees for root-level sequences, lists, and definition lists. The trees expose two existing defects, pinned as known bugs: adjacent lists of the same kind merge into one loose list, and a description holding only a list turns its first item into an indented code block.
List and definition list writers mixed up two kinds of newline: the one that ends a block, and the blank line that separates two sibling blocks. Items and term groups pushed unconditional newlines on top of children that already ended their own lines, which left extra blank lines after lists, code blocks, and nested definition lists, and could make a tight list read as loose. Introduce explicit helpers for the two: a terminator that ends a block fragment, and a separator that writes the blank line between siblings. Every non-empty block fragment now ends with exactly one newline, and containers insert separators only between siblings. Raw HTML and empty tables or lists stay outside the contract; containers close the line after them. Output changes are limited to removed blank lines. Converting the man pages of several real packages with the old and new binaries changes 42 of 1179 files, all by removing blank lines, with identical Pandoc ASTs.
The pulldown-cmark tree dropped the text after an inline tag such as emphasis or a link, so two items with different labels could compare equal. Rows also joined their cells with " | ", which made one cell containing "a | b" indistinguishable from two cells. Skip inline tags before flushing block text, and render rows as cell arrays. Also pin how inline nodes placed directly in a definition description are written.
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.
Summary
The list and definition list writers mixed up two kinds of newline: the one that ends a block, and the blank line between sibling blocks. Children that already ended their own lines got another newline on top, which left extra blank lines after lists, code blocks, and nested definition lists, and could make a tight list read as loose.
test:commits)pandocbinary is available,pandoc -f markdown, and render a normalized block tree: which blocks exist, how they nest, and whether lists are tight or loose.RD2QMD_REQUIRE_PANDOCto make a missing Pandoc a failure; the CI test job installs Pandoc 3.7.0.2 withr-lib/actions/setup-pandocand sets it, so both oracles run on all three OSes.fix:commit)Output changes
Removed blank lines only.
definition-list,list, andheadingsdescribe formats: 42 of 1179 files differ (20 forheadings), all by removed blank lines with no added lines, and the Pandoc AST is identical under both themarkdownandcommonmarkreaders.