Repository navigation
fix: keep the first item of a list that starts a definition description - #112
Merged
Merged
Conversation
When a definition description began with a list, the list indented every item by 4 spaces, including the first one, which already follows the `: ` marker. The first item then sat 8 columns in and was read as an indented code block by both Pandoc and pulldown-cmark. The list writer was the only block writer that took an absolute indent and indented its own items. Every other block is written from the current column, with the container writing the first line's prefix and re-indenting the rest. Drop the list's base indent and nest lists the same way, so the `: ` marker is the first item's prefix.
Nested blocks now share one helper that writes the first line's prefix and re-indents the rest. When the block writes nothing (an empty list, table, or raw HTML), the prefix was left on a whitespace-only line, so an item holding only an empty nested list gained a blank line and made its list loose. Drop the prefix together with the empty block. Also check per definition that each term keeps its own list items in the CLI test, and update the stale ListContext docs.
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
When a
\describe{}item's description is only a list, the definition-list output indented the first item past the:marker:Both Pandoc and pulldown-cmark (definition list extension) read the first item as an indented code block, and only the remaining items as a list. Now:
Cause and fix
The list writer was the only block writer that took an absolute indent (
base_indent) and indented its own items. Every other block is written from the current column, with the container writing the first line's prefix and re-indenting the continuation lines. In a definition description the container had already written:, and the list added its own 4 spaces on top.Instead of special-casing the first item, drop the list's base indent and nest lists the same way as other blocks: nested lists in list items and lists in definition descriptions are now re-indented by their container, and the
:marker serves as the first item's prefix.Nested blocks now go through one helper that writes the first line's prefix and re-indents the rest. When the nested block writes nothing (an empty list, table, or raw HTML), the prefix is dropped too, so no whitespace-only line is left behind; otherwise an item holding only an empty nested list would gain a blank line and make its list loose.
Tests
Writer exact-output tests for lists inside definition descriptions are updated to the corrected first line.
The block-structure test that pinned this as a known bug now expects a single list inside the definition, under both pulldown-cmark and Pandoc. Two cases are added: a description holding only an ordered list with wide numbers, and a list followed by a paragraph.
A CLI-level test converts an Rd
\describe{}whose descriptions are\itemize{}/\enumerate{}and checks that no code block appears and each term keeps its own list items. It fails on the previous implementation.Exact-output tests for empty nested blocks (empty list, empty table) inside list items and definition descriptions.
Output changes
Only descriptions that start with a list change. Converting the man pages of several real packages with the previous and new binaries in all three describe formats produced no differences (3558 files); the pattern does not occur in them.