fix(lint): preserve Obsidian heading, block, and embed link syntax#180
Open
Aldominguez12 wants to merge 1 commit into
Open
fix(lint): preserve Obsidian heading, block, and embed link syntax#180Aldominguez12 wants to merge 1 commit into
Aldominguez12 wants to merge 1 commit into
Conversation
9d33a56 to
2775a3a
Compare
The single-capture wikilink regex treated [[page#Heading]], [[page#^block]], ![[file.png]] and [[report.pdf]] as whole page targets. None of them can ever match a known target, so lint --fix (strip_ghost_wikilinks) demoted valid Obsidian links to plain text — silently destroying hand-written notes in explorations/ on a full sweep — and find_broken_links reported them all as broken. - Parse the embed marker, target, fragment and alias as named groups. - Validate only the page target; fragments survive fuzzy canonical rewrites ([[concepts/Gist_Memory#Notes]] -> [[concepts/gist-memory#Notes]]). - Pass through attachment embeds/links (extension whitelist) and same-page [[#Heading]] links untouched. - Treat note embeds ![[concepts/x]] as regular page links: validated, rewritten keeping the embed marker, counted as incoming links for orphan detection and as graph edges in visualize. Adds regression coverage including a hand-written explorations/ note that must survive a wiki-wide lint --fix byte-for-byte. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2775a3a to
e8900ac
Compare
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.
Problem
The wikilink regex in
openkb/lint.pycaptured the whole[[...]]body as a single page target. Valid Obsidian syntax therefore never matched a known target:[[page#Heading]]/[[page#^block]]— heading and block links![[file.png]]/[[report.pdf]]— attachment embeds and links[[#Heading]]— same-page fragment links![[concepts/x]]— note embedsConsequences:
openkb lint --fixdestroyed valid links:strip_ghost_wikilinksdemoted them to plain text. A wiki-wide sweep silently mangled hand-written notes inexplorations/— a data-loss path.openkb lintreported them all as broken links (false positives).visualizeand could produce false orphans.Fix
[[concepts/Gist_Memory#Notes]]→[[concepts/gist-memory#Notes]]).[[#Heading]]links untouched.![[concepts/x]]as regular page links: validated, rewritten keeping the!, counted as incoming links for orphan detection, and picked up as graph edges byvisualize(which reuses_extract_wikilinks).Verification
TestObsidianSyntaxcoverage: heading/block/fragment preservation through direct and fuzzy matches, ghost demotion without!residue, attachment/note embed handling, and a regression test asserting a hand-writtenexplorations/note survives a wiki-widelint --fixbyte-for-byte.pytest tests/test_lint.py tests/test_lint_cli.py tests/test_visualize.py tests/test_chat_session.py tests/test_remove.pygreen;ruff check/formatandmypy openkb/lint.pyclean.🤖 Generated with Claude Code