Skip to content

fix: keep the first item of a list that starts a definition description - #112

Merged
eitsupi merged 2 commits into
mainfrom
fix/describe-list-first-item
Nov 14, 2026
Merged

eitsupi merged 2 commits into
mainfrom
fix/describe-list-first-item

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

When a \describe{} item's description is only a list, the definition-list output indented the first item past the : marker:

a
:       - one
    - two

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:

a
:   - one
    - two

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.

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.
@eitsupi
eitsupi merged commit 8c05d7f into main Nov 14, 2026
14 checks passed
@eitsupi
eitsupi deleted the fix/describe-list-first-item branch November 14, 2026 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant