Skip to content

[Bug] Formatter removes angle brackets in link destinations #179

@charlesroper

Description

@charlesroper

Describe the bug

dprint-plugin-markdown version: 0.21.1

The formatter removes functional angle brackets (< >) from inline Markdown links. While this simplifies the syntax for basic URLs, it breaks links that contain spaces, parentheses, and ASCII control characters. According to the CommonMark specification (Section 6.3), angle brackets are the standard method for protecting complex URIs. Stripping them results in invalid Markdown that modern parsers - including those used by GitHub, VS Code, and Obsidian - cannot navigate.

Input Code

[Scratch](<00 Top/001 Scratch.md>)
[Note](<Folder/File (Draft).md>)

Expected Output

The brackets should be preserved to maintain link integrity:

[Scratch](<00 Top/001 Scratch.md>)
[Note](<Folder/File (Draft).md>)

Actual Output

The brackets are stripped, breaking the links in most parsers:

[Scratch](00 Top/001 Scratch.md)
[Note](Folder/File (Draft).md)

Suggested Options

I suggest, as an opinionated default, preserve the angle brackets if they exist, rather than strip them.

A more comprehensive solution could be a new configuration option, such as linkDestinationStyle, to give users control over this behaviour:

  • maintain (default): Leave angle brackets exactly as the author wrote them.
  • always: Automatically add angle brackets all link destinations for consistency and robustness.
  • optimal: Strip brackets only if the path contains no spaces or special characters.
  • remove: Strip all angle brackets around link destinations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions