mirror of
https://github.com/Ar9av/obsidian-wiki.git
synced 2026-09-14 20:36:34 +08:00
f268d43744
* fix(lint): stop flagging embeds and normalise .md/escaped-pipe wikilink targets broken_links harvests every [[wikilink]] target, including embeds (![[diagram.png]], [[board.canvas]], [[dashboard.base]]) that by_slug can never hold since _iter_pages globs only *.md. An explicit .md suffix ([[alpha.md]]) and a table-escaped pipe ([[beta\|B]]) were also compared raw against the slugged index instead of being normalised the way _normalise_node_id already normalises a page's own id, so both never resolved either. _wikilink_page_target() returns None for a non-.md-extension target (skipping attachment embeds) and otherwise strips an explicit .md suffix and a trailing backslash before _parse_page slugs it. On the issue's own repro vault this drops broken_links from 7 flagged (6 false positives) to the one genuinely broken link. Fixes #176 * fix(lint): only skip attachment extensions, not every dotted page name Path("Node.js").suffix is ".js", so the previous `if suffix: return None` dropped links to any page whose name contains a dot. Those links feed orphan detection and link_count as well as broken_links, so "Node.js", "Next.js", "v1.2 release notes" and friends were reported as orphans. Skip only Obsidian's attachment extensions instead. --------- Co-authored-by: ar9av <ar9avg@gmail.com>
20 lines
743 B
Python
20 lines
743 B
Python
import sys, tempfile, pathlib, json
|
|
sys.path.insert(0, ".")
|
|
from obsidian_wiki.lint import lint_vault
|
|
|
|
def page(v, rel, links=()):
|
|
p = v / rel; p.parent.mkdir(parents=True, exist_ok=True)
|
|
body = "\n".join(f"- [[{l}]]" for l in links)
|
|
p.write_text(
|
|
"---\ntitle: T\ncategory: concepts\ntags: [a]\nsources: []\n"
|
|
"created: 2026-01-01\nupdated: 2026-01-01\nsummary: s\n---\n\n" + body + "\n",
|
|
encoding="utf-8")
|
|
|
|
v = pathlib.Path(tempfile.mkdtemp()) / "vault"
|
|
page(v, "entities/Node.js.md")
|
|
page(v, "concepts/index.md", links=["Node.js"])
|
|
r = lint_vault(v)
|
|
print("broken_links:", r["findings"]["broken_links"])
|
|
print("orphan_pages:", r["findings"]["orphan_pages"])
|
|
print("link_count:", r["stats"]["link_count"])
|