fix: stop resolveMdLinks from breaking dataview links - #400
Merged
Conversation
The resolveMdLinks filter added in 1.83.0 (#398) sent every dataview-generated link to /404, two defects compounding: - convertMdHrefs' anchor regex matched the tail of data-href=", so dataviewjs anchors (<a data-href="Folder/Note.md" href=...>) had their data-href clobbered to /404 before the dataview-js-links transform could resolve the anchor from it. The regex now requires href to be a standalone attribute. - resolveVaultPath treated vault-root targets (Folder/Note.md, as dataview and Obsidian's "absolute path in vault" setting emit) as note-relative, so links from nested notes resolved to paths that don't exist. Targets now yield ordered candidate interpretations, note-relative first, vault-root as fallback, and the filter picks the first that resolves to a real note. Dead links keep the /404 + is-unresolved handling. Verified with unit tests (TDD, 6 new failing tests before the fix) and an end-to-end build of the test garden covering dataviewjs anchors, vault-absolute and relative .md links. Fixes #399 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #399
Problem
The
resolveMdLinksfilter shipped in 1.83.0 (#398) sent every dataview-generated link to/404. Two defects compounded:convertMdHrefs' anchor regex(<a\s[^>]*?href=")also matched the tail ofdata-href=". DataviewJS output contains Obsidian-rendered anchors like<a data-href="Folder/Note.md" href="Folder/Note.md" class="internal-link">. The lazy[^>]*?atedata-, so the filter rewrote thedata-hrefattribute to/404. The pre-existingdataview-js-linkstransform — which resolves these anchors fromdata-href— then read the clobbered value and marked every dataview link unresolved.resolveVaultPathtreated vault-root targets as note-relative. Dataview (and Obsidian's "absolute path in vault" link setting) emit targets likeFolder/Note.mdwith no.//../prefix. For notes in subfolders these were joined with the note's directory, the lookup missed, and the href became/404.Fix
hrefto be a standalone attribute ((?:[^>]*?\s)?href="), sodata-hrefis never rewritten.resolveMdLinkspicks the first candidate that resolves to a real note; only when none do does it keep the/404+is-unresolvedhandling. Graph extraction emits all candidates; ones matching no note are dropped as before.Verification
.mdlinks, and relative.mdlinks — all resolve to real permalinks; genuinely dead links still get/404withis-unresolved.🤖 Generated with Claude Code