Skip to content

fix: ignore URL fragments in markdown links when parsing tags (#52)#58

Merged
mfarragher merged 1 commit into
mfarragher:dev_with_propertiesfrom
MohammadYusif:fix/issue-52
Jun 7, 2026
Merged

fix: ignore URL fragments in markdown links when parsing tags (#52)#58
mfarragher merged 1 commit into
mfarragher:dev_with_propertiesfrom
MohammadYusif:fix/issue-52

Conversation

@MohammadYusif

Copy link
Copy Markdown

Summary

  • A URL fragment inside a standard markdown link (e.g. [Vite's HMR](https://vitejs.dev/guide/features.html#hot-module-replacement)) was incorrectly returned as a tag (hot-).
  • get_tags strips wikilinks before tag parsing but never strips standard markdown inline links, so the #fragment in a link URL reached the tag regex and matched.

Changes

  • obsidiantools/md_utils.py: added _remove_md_link_urls_from_source_text, which replaces [text](url) with its display text using the existing INLINE_LINK_AFTER_HTML_PROC_REGEX, and calls it in get_tags right after wikilink removal. Link text is preserved so a genuine #tag written in visible text is still captured; only the URL and its #fragment are dropped.
  • tests/general/tags_url-fragment.md: new fixture reproducing the issue.
  • tests/test_md_utils.py: two regression tests via the public get_tags API (default and show_nested=True). Both fail without the fix and pass with it.

Fixes #52

…gher#52)

get_tags removed wikilinks before tag parsing but left standard markdown
inline links intact, so a URL fragment such as
'.../features.html#hot-module-replacement' was matched by the tag regex
and surfaced as a spurious tag ('hot-').

Strip the link URLs (keeping the link text) before tag extraction, using
the existing INLINE_LINK_AFTER_HTML_PROC_REGEX, mirroring how wikilinks
are already handled. Genuine tags, including a '#tag' written in a link's
display text, are still captured.
@mfarragher mfarragher merged commit 642ec03 into mfarragher:dev_with_properties Jun 7, 2026
0 of 10 checks passed
@mfarragher

Copy link
Copy Markdown
Owner

Nice - approved and merged

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.

2 participants