Skip to content

feat(MD054): auto-fix support for converting inline links to reference style #587

@zolotokrylin

Description

@zolotokrylin

Summary

MD054 correctly detects inline links ([text](url)) when inline = false is configured, but rumdl check --fix leaves the file unchanged — no auto-fix is applied.

Expected behavior

Running rumdl check --fix with inline = false in [MD054] should convert inline links to reference-style:

Before:

See the [documentation](https://example.com/docs) for details.

After:

See the [documentation][documentation] for details.

[documentation]: https://example.com/docs

Suggested implementation

  1. Collect all inline links in the file (skipping code spans and fenced blocks).
  2. For each link, derive a slug label from the link text (lowercased, spaces → hyphens).
  3. Deduplicate: reuse the same label when the same URL appears more than once; generate a -2, -3 suffix when the same text maps to different URLs.
  4. Replace each [text](url) with [text][label].
  5. Append new [label]: url definitions at the end of the file (skip any that already exist).

The same logic should apply to images (![alt](url)![alt][label]) when the inline style is disallowed.

Environment

  • rumdl version: 0.1.80
  • Config:
[global]
extend-enable = ["MD054"]

[MD054]
inline = false
autolink = true

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions