mdsmith
Esc
    v0.52.0 GitHub
    MDS070 link ready

    MDS070: same-file-anchor

    Every same-file #fragment link must resolve to a heading present in the same file.

    A same-file fragment link has a destination beginning with # and no path component — for example [text](#my-heading).

    The rule computes GitHub-flavored Markdown heading slugs: lowercase, spaces become -, and non-alphanumeric characters except - are removed. Any fragment that does not match a slug in the file is reported.

    This rule is parse-skip-safe: it does not require a goldmark AST. It works on the Layer 0 block-span projection and the shared inline-block parser.

    # Config

    Enable (default):

    rules:
      same-file-anchor: true

    Disable:

    rules:
      same-file-anchor: false

    # Examples

    # Bad

    # My Heading
    
    See [link](#nonexistent-section).

    Reports: same-file anchor #nonexistent-section does not match any heading in this file

    # Good

    # My Heading
    
    See [link](#my-heading).
    
    ## Another Section
    
    See [another link](#another-section).

    # See also

    • MDS027 — cross-file link and anchor resolution; this rule handles only same-file #fragment links

    # Meta-Information

    • ID: MDS070
    • Name: same-file-anchor
    • Status: ready
    • Default: enabled
    • Fixable: no
    • Implementation: source
    • Category: link
    • markdownlint: MD051 (link-fragments)
    • rumdl: MD051 (link-fragments)
    • gomarklint: link-fragments