Skip to content

fix(MD070): skip a fence that ends with its list item - #967

Merged
rvben merged 1 commit into
rvben:mainfrom
andreashaerter:fix/md070-fence-ends-with-container
Oct 20, 2026
Merged

rvben merged 1 commit into
rvben:mainfrom
andreashaerter:fix/md070-fence-ends-with-container

Conversation

@andreashaerter

Copy link
Copy Markdown
Contributor

Description

CommonMark ends a fenced code block that has no closing fence with the
list item that holds it. MD070 kept searching the rest of the document
for a closing fence, so with

- Item:

  ```yaml
  key: |
    raw

After the list.

```text
plain
```

it reported the text fence as a collision inside the yaml block. Its
fix turned the yaml fence into four backticks and closed it after the
text block, so "After the list." and the second block rendered as code.
markdown-it's commonmark preset reads the same document as two separate
blocks with a paragraph between them.

Since 0.3.0 the same document also gives different results on stdin and
on a file. rumdl fmt - leaves it unchanged and prints "0 issues fixed,
1 issue remaining", while rumdl fmt file.md applies the fix; 0.2.79
applied it in both. The formatter skips rules the format proof covers.
The proof reads the parser's blocks and finds no collision, so stdin
skips MD070, while the file path runs MD070's own scan.

The check now skips a fence the parser marks as not closed
(CodeBlockDetail.closed, which MD031 uses since 0.3.0), so MD070 and
the proof read the document the same way. Fences the parser closes are
checked as before, and a nested collision inside a list item is still
reported (test_indented_code_block_in_list).

Type of Change

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update

Testing

  • Tests added: test_unclosed_fence_ends_with_its_list_item for MD070
    and fence_ended_by_its_list_item_is_proven_for_md070 for the format
    proof (through assert_proofs). Both fail without the change; the proof
    test reports "MD070 incorrectly proved unchanged".
  • cargo test --no-fail-fast with Rust 1.96.1 (the test-legacy
    target, since nextest was not available in my build container). All
    tests pass except timing tests in perf::rule_complexity_regression_test
    and test_performance_many_consecutive_items. Those failed the same way
    on unchanged main in the same container, a debug build on a busy host,
    and the failing set changes from run to run.
  • Manual testing: the document above with rumdl check,
    rumdl fmt - and rumdl fmt file.md, before and after the change.

Checklist

  • Code follows project style (cargo fmt --check, and cargo clippy --workspace --lib --bins --tests -- -D warnings -D clippy::uninlined_format_args)
  • Conventional commit messages used (they generate the changelog)
  • Documentation updated (not needed)

CommonMark ends a fenced code block that has no closing fence with the
list item that holds it. MD070 searched the rest of the document for a
closing fence instead, so a later, separate fenced block counted as a
collision, and the fix wrapped the text between them into one code block.

The check now skips a fence the parser marks as not closed
(CodeBlockDetail.closed). MD070 then reads the document the way the
format proof does, so `rumdl fmt -` and `rumdl fmt <file>` give the same
result. Before, the proof skipped MD070 on stdin, while the file path
applied the wrong fix.
@rvben
rvben merged commit 3be9c0c into rvben:main Oct 20, 2026
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.

2 participants