Skip to content

Preserve underscores in inline-code heading slugs (false broken anchors in v0.0.9) #40

Closed

Description

@JAORMX

Reproduction

With matlatl v0.0.9, save this as README.md in an otherwise empty directory:

# Underscore anchors

## `credential_store`

[Credential store](#credential_store)

Run:

go run github.com/stacklok/matlatl/cmd/[email protected] check . --strict

Verified result:

matlatl check: 1 documents, 1 references — 0 broken link(s), 1 broken anchor(s), 0 ambiguous, 0 orphan(s), 0 unreachable

Expected

The link resolves. The underscore is literal content inside a code span and must remain in the heading's slug.

Real corpus and independent verification

After adopting v0.0.9 and contentRoots: [user-docs] in stacklok/mecatl#1934, the original Docusaurus reproduction from #37 passes, all 372 content-root link errors disappear, and all 377 MDX heading-anchor errors disappear. Thank you for that support.

Five newly resolvable cross-document links still fail against four headings in the generated configuration reference:

## `credential_store`
## `harness_context`
## `command_runner`
## `temporary_storage`

I ran task site:build successfully and parsed the actual built website/build/docs/reference/configuration/index.html using Python's HTMLParser. It contains these exact elements:

h2 credential_store
h2 harness_context
h2 command_runner
h2 temporary_storage

The five links use those same literal IDs. Changing the links to match matlatl would break the rendered site, so the consumer PR remains draft rather than weakening checks or altering published anchors.

Regression coverage requested

  • Underscores in inline-code heading text survive text extraction and slug generation.
  • Local and cross-document links to these anchors resolve.
  • Genuine missing anchors still fail.
  • Preserve ordinary Markdown emphasis handling and duplicate-heading suffix behavior.

This appears independent of the new content-root feature: the one-file reproduction has no Docusaurus config or MDX.

Relates to #37. Blocks stacklok/mecatl#1934.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions