Skip to content

Preserve readable inline link wrapping #321

Description

@lodyai

Summary

mdtablefix --wrap can reflow Markdown links into visually awkward shapes by moving the opening parenthesis onto a line after the link text.

The resulting Markdown may still parse, but it is harder to read and review in source form.

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

Example

In docs/archive/parser-plan.md, a wrapped inline link is reshaped like this:

-3. For syntactic errors, emit an `N_ERROR` node and recover by skipping to a
-   known synchronization point, as recommended by the design document ([design
-   document](docs/ddlint-design-and-road-map.md#L124-L139)).
+3. For syntactic errors, emit an `N_ERROR` node and recover by skipping to a
+   known synchronization point, as recommended by the design document
+   ([design document](docs/ddlint-design-and-road-map.md#L124-L139)).

Expected behaviour

The wrapper should keep inline links readable in source form. In particular, it should avoid introducing a line break between surrounding prose and the ([link text](target)) construct when the original text is already valid and readable.

Actual behaviour

The formatter moves the parenthesized link to a new continuation line, creating unnecessary churn and a less readable source layout.

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