mdsmith
Esc
    v0.52.0 GitHub
    MDS054 link ready

    MDS054: no-undefined-reference-labels

    Reference-style links and images must have a matching link reference definition in the same file.

    # Settings

    SettingTypeDefaultDescription
    shortcutstringheuristicControls when bare [label] shortcut references are checked: heuristic, always, or collapsed-only.
    placeholderslist[]Placeholder tokens to treat as opaque; see placeholder grammar

    # shortcut values

    ValueBehaviour
    heuristicFlag bare [label] only when the label has no spaces and contains a digit, hyphen, or underscore. Image shortcuts (![label]) are always checked regardless of this setting.
    alwaysFlag every bare [label] whose definition is missing.
    collapsed-onlyOnly flag [text][label] (full) and [label][] (collapsed) forms; never bare [label].

    # Config

    rules:
      no-undefined-reference-labels:
        shortcut: heuristic
        placeholders: []

    Disable:

    rules:
      no-undefined-reference-labels: false

    # Examples

    # Good

    # Full Reference
    
    See [example][site] for more.
    
    [site]: https://example.com

    # Good – collapsed reference

    # Collapsed Reference
    
    See [example][] for more.
    
    [example]: https://example.com

    # Good – prose brackets skipped by heuristic

    # Prose Brackets
    
    Use [just brackets] in prose without a definition; the heuristic
    skips it because the label has spaces.

    # Bad – undefined full reference

    # Undefined Full Reference
    
    See [example][broken] for more.

    # Bad – undefined collapsed reference

    # Undefined Collapsed Reference
    
    See [broken][] for more.

    # Bad – undefined shortcut (heuristic)

    # Shortcut Heuristic
    
    See [plan128] for the plan.

    # Diagnostics

    ConditionMessage
    undefined full referencereference label “X” has no matching link reference definition
    undefined collapsed referencereference label “X” has no matching link reference definition
    undefined shortcut (flagged)reference label “X” has no matching link reference definition

    # Background

    goldmark only constructs an *ast.Link for a reference-style usage when a matching link reference definition exists. When the definition is missing, goldmark leaves the bracketed text as plain text. A source-level scan is required to detect these dropped patterns.

    Reference labels are CommonMark-normalized before lookup: case-folded, inner whitespace collapsed, and ends trimmed. [Foo Bar][BAR] resolves against [bar]: url.

    # See also

    # Meta-Information

    • ID: MDS054
    • Name: no-undefined-reference-labels
    • Status: ready
    • Default: enabled, shortcut: heuristic, placeholders: []
    • Fixable: no
    • Implementation: source
    • Category: link
    • markdownlint: MD052 (reference-links-images)
    • rumdl: MD052 (reference-links-images)
    • panache: undefined-references