From 70e0ed5debf46d8fe243bb22de3532221166517b Mon Sep 17 00:00:00 2001 From: Rosa Hase <1872366+daxcore@users.noreply.github.com> Date: Fri, 28 Nov 2025 17:10:17 +0100 Subject: [PATCH] added initial support for plain markdown links --- obsidian_interactive_graph/plugin.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/obsidian_interactive_graph/plugin.py b/obsidian_interactive_graph/plugin.py index 552e2c6..8e58579 100755 --- a/obsidian_interactive_graph/plugin.py +++ b/obsidian_interactive_graph/plugin.py @@ -54,10 +54,13 @@ def collect_pages(self, nav: MkDocsNav, config: MkDocsConfig): } def parse_markdown(self, markdown: str, page: MkDocsPage): - # wikilinks: [[Link#Anchor|Custom Text]], just the link is needed - WIKI_PATTERN = re.compile(r"(?[^\|^\]^\#]{1,})(?:.*?)\]\]") + # wikilinks: just the link is needed + # Obsidian: [[Link#Anchor|Custom Text]] + # Markdown: [Custom Text](Link) + WIKI_PATTERN = re.compile(r"(?[^\|^\]^\#]+)(?:.*?)\]\]|(?[^\)^\#]+)(?:#[^\)]*)?\)") + for match in re.finditer(WIKI_PATTERN, markdown): - wikilink = match.group('wikilink') + wikilink = match.group('obsidianlink') or match.group('markdownlink') # get the nodes key page_path = self.get_page_path(page) @@ -75,10 +78,10 @@ def parse_markdown(self, markdown: str, page: MkDocsPage): # find something that matches: shortest path depth abslen = None - for k,_ in self.nodes.items(): + for k, _ in self.nodes.items(): for _ in re.finditer(re.compile(r"(.*" + wikilink + r")"), k): curlen = k.count('/') - if abslen == None or curlen < abslen: + if abslen is None or curlen < abslen: target_page_path = k abslen = curlen