Skip to content

Avoid broad paragraph reflow churn for already wrapped Markdown #320

Description

@lodyai

Summary

Running mdtablefix --wrap --renumber --breaks --ellipsis --fences --in-place over an already wrapped documentation set causes broad paragraph reflow churn even when the existing text already satisfies the 80-column rule.

This makes formatter output hard to review because many unrelated prose lines are changed without an obvious formatting defect being fixed.

Reproduction

From leynos/ddlint on branch docs/import-rust-agent-template:

fd --print0 --type f --extension md --extension markdown --extension mdx . \
  | xargs -0 mdtablefix --wrap --renumber --breaks --ellipsis --fences --in-place

Examples

In docs/developers-guide.md, the formatter rewrites an already compliant opening paragraph:

-This guide records the parser module structure introduced by issue `#223`.
-It is intentionally narrow and documents ownership boundaries rather than the
-full parsing pipeline.
+This guide records the parser module structure introduced by issue `#223`. It
+is intentionally narrow and documents ownership boundaries rather than the full
+parsing pipeline.

In docs/ddlint-design.md, it also joins and repartitions inline-code prose:

-acts as the bridge, with its `kind_from_raw` and `kind_to_raw` methods using
-the `FromPrimitive` and `ToPrimitive` implementations to connect the specific
-DDlog grammar to the generic `rowan` machinery.[^2]
+acts as the bridge, with its `kind_from_raw` and `kind_to_raw` methods using the
+`FromPrimitive` and `ToPrimitive` implementations to connect the specific
+DDlog grammar to the generic `rowan` machinery.[^2]

Expected behaviour

When --wrap encounters paragraphs that already comply with the configured line length, it should avoid avoidable churn or expose a mode that preserves existing compliant wraps.

Actual behaviour

The formatter greedily refills paragraphs, producing large diffs across documents that were already wrapped acceptably.

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