Skip to content

--wrap collapses pre-wrapped inline-code spans into a single over-long line (MD013) #370

Description

@lodyai

Summary

When --wrap encounters an inline-code span that an author has wrapped across
multiple lines (each line within the wrap width), it collapses the whole span
onto a single line. Because the wrapper will not insert a break inside an
inline-code span, the result is a line that exceeds the wrap width — turning a
clean document into one that fails markdownlint MD013 (line-length).

Version

mdtablefix 0.4.0

Reproduction

Input (wrap.md), every line <= 80 columns:

# Wrap repro

This plan covers roadmap item 4.1.1 only:
`Implement backend/crates/pagination providing opaque cursor encoding,
PageParams, and Paginated<T> envelopes with navigation links, backed by unit
tests for cursor round-tripping.`

Command:

mdtablefix --wrap --renumber --breaks --ellipsis --fences --in-place wrap.md

Actual behaviour

The three wrapped lines collapse to one 181-column line:

< `Implement backend/crates/pagination providing opaque cursor encoding,
< PageParams, and Paginated<T> envelopes with navigation links, backed by unit
< tests for cursor round-tripping.`
---
> `Implement backend/crates/pagination providing opaque cursor encoding, PageParams, and Paginated<T> envelopes with navigation links, backed by unit tests for cursor round-tripping.`

Expected behaviour

A reflow pass run with --wrap should not produce lines longer than the wrap
width. Since a line ending inside an inline-code span renders as a space,
breaking the span across lines at a space is safe and preserves rendering; the
wrapper could keep (or re-introduce) such breaks instead of collapsing the
span onto one over-long line. At minimum, spans that cannot be wrapped within
the limit should be left in their already-conforming multi-line form.

Impact

Documents that were previously markdownlint-clean fail MD013 after formatting,
with no automatic fix available (markdownlint --fix does not wrap MD013).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions