whateverforever/zettelcon

non-wiki/markdown links

Closed this issue · 3 comments

I'm interested in using this for a bunch of inter-linked markdown files which don't use wiki-links and instead use more vanilla markdown syntax, like this:
[filename](./filename.md)

If I wanted to modify this to work with such links, do I just need to edit the regex in line 17?

Or is there other code I'd need to change as well?

yes, I think that should do it. Have you tried it?

Got it working, mostly.
Updated line 17 to read this instead:
REX_LINK = re.compile(r"\[([^\]]*)\]\([^\)]+(?<=\.md)\)")
and it's correctly picking out links, but only if the link text matches the filename/destination exactly. (This obviously makes sense for wiki-style links, but it'd be nice to have more flexibility with markdown links.)

I thought perhaps changing the link_target to res.group(2) might help by selecting the path only, but seems like there are a few other things I'd need to change, too.

I replaced the default capture group with a named one. So the only thing the regex needs to provide is a capture group named "linktarget": https://github.com/whateverforever/zettelcon/blob/main/zettelcon.py#L17

Should be fairly easy to adapt now