Skip to content

fix: navigate to heading for internal anchor links#16

Merged
bahdotsh merged 3 commits into
mainfrom
fix/internal-anchor-links
Mar 16, 2026
Merged

fix: navigate to heading for internal anchor links#16
bahdotsh merged 3 commits into
mainfrom
fix/internal-anchor-links

Conversation

@bahdotsh
Copy link
Copy Markdown
Owner

Summary

  • Internal anchor links (e.g. [foo](#foo)) now navigate to the matching heading instead of being blocked as unsupported URL schemes
  • Adds a heading_to_slug() function that converts heading text to GitHub-style anchor slugs for matching
  • Closes Links within the markdown file do not work #14

Test plan

  • Open a markdown file containing internal anchor links (e.g. [foo](#foo) with a # foo heading)
  • Open the link picker (l), select the anchor link, and verify it scrolls to the heading
  • Verify external links (http://, https://, mailto:) still open normally
  • Verify headings with special characters and mixed case match correctly

Handle #anchor links in the link picker by matching against TOC headings
instead of blocking them as unsupported URL schemes. Closes #14.
Use idiomatic filter_map, Unicode-aware lowercasing, and add unit tests
covering basic slugs, punctuation, consecutive hyphens, Unicode, and edge cases.
Handle multi-char Unicode lowercasing (e.g. ß→ss), collapse consecutive
hyphens, and trim leading/trailing hyphens to align with GitHub's slug
algorithm. Add tests for these edge cases.
@bahdotsh bahdotsh merged commit 7783912 into main Mar 16, 2026
5 checks 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.

Links within the markdown file do not work

1 participant