mirror of
https://github.com/safishamsi/graphify.git
synced 2026-10-14 07:59:40 +00:00
fix(markdown): parse escaped wikilink aliases
This commit is contained in:
1 parent
a5957aa6ef
commit
f50f96f3c8
2 files changed
+13
-1
No files matched your search
@@ -15,7 +15,7 @@ _MD_INLINE_LINK_RE = re.compile(r'(?<!\!)\[[^\]]*\]\(\s*<?([^)\s>]+)>?(?:\s+[^)]
|
||||
|
||||
_MD_REF_DEF_RE = re.compile(r'^\s{0,3}\[[^\]]+\]:\s*<?([^\s>]+)>?')
|
||||
|
||||
_MD_WIKILINK_RE = re.compile(r'(?<!\!)\[\[([^\]|#]+)(?:[#|][^\]]*)?\]\]')
|
||||
_MD_WIKILINK_RE = re.compile(r'(?<!\!)\[\[([^\]|#]+?)(?:\\?\|[^\]]*|#[^\]]*)?\]\]')
|
||||
|
||||
_MD_LINKABLE_EXTS = {".md", ".mdx", ".qmd", ".markdown", ".rst", ".txt"}
|
||||
|
||||
|
||||
@@ -3037,6 +3037,18 @@ def test_markdown_wikilink_vault_fallback(tmp_path):
|
||||
assert e["target"] in node_ids, f"link target is a ghost node: {e}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("separator", ["|", "\\|"])
|
||||
def test_markdown_wikilink_alias_separator(tmp_path, separator):
|
||||
r"""Obsidian table aliases escape the pipe as ``\|``."""
|
||||
target = tmp_path / "target.md"
|
||||
source = tmp_path / "source.md"
|
||||
target.write_text("# Target\n")
|
||||
source.write_text(f"| Link |\n| --- |\n| [[target{separator}Alias]] |\n")
|
||||
refs = [e for e in extract_markdown(source)["edges"]
|
||||
if e["relation"] == "references"]
|
||||
assert [e.get("target_file") for e in refs] == [str(target)]
|
||||
|
||||
|
||||
def test_markdown_wikilink_fallback_path_qualified(tmp_path):
|
||||
"""[[folder/name]] from a subfolder matches on the full segment suffix."""
|
||||
vault = tmp_path / "vault"
|
||||
|
||||
Reference in new issue
Block a user