Skip to content

Fix non-ASCII heading anchors not navigating from links - #64

Merged
patakuti merged 1 commit into
mainfrom
fix/non-ascii-heading-anchor
Jun 20, 2026
Merged

Fix non-ASCII heading anchors not navigating from links#64
patakuti merged 1 commit into
mainfrom
fix/non-ascii-heading-anchor

Conversation

@patakuti

@patakuti patakuti commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Closes #63

Summary

  • goldmark's default IDs generator skips multi-byte UTF-8 characters, so headings like # ヘディング get id="heading" (fallback) instead of id="ヘディング"
  • Added gfmIDs in internal/markdown/headingid.go: a GFM-compatible ID generator that preserves Unicode letters/digits (Japanese, Chinese, etc.) and lowercases ASCII letters
  • Injected it via parser.NewContext(parser.WithIDs(newGFMIDs())) in Convert()

Test plan

  • go test ./internal/markdown/... — new TestConvert_NonASCIIHeadingAnchor covers Japanese-only, mixed, and ASCII-only headings
  • Open a Markdown file containing [ヘディング](#ヘディング) and # ヘディング and verify the link navigates correctly in the browser

🤖 Generated with Claude Code

goldmark's default ID generator skips multi-byte UTF-8 characters,
causing Japanese/non-ASCII headings to fall back to "heading" as the
id. Replace it with a GFM-compatible implementation that preserves
Unicode letters and digits so links like [text](#ヘディング) work.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@patakuti
patakuti merged commit 1985755 into main Jun 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-ASCII heading anchors do not work as link targets

1 participant