mdzk-rs / mdzk

General-purpose interface to connected notes

Home Page:https://mdzk.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom wikilink parser

kmaasrud opened this issue · comments

For increased speed and greater robustness, we want to tie into the pulldown-cmark event iterator to find and replace wikilinks. This is easily done since pulldown-cmark notices brackets (not used in links) as separate Text events. Using this fact, we can find a wikilinks internals and use a Pest parser to handle the link's logic. A simple replacen on the original content will then finalize the conversion.

One disadvantage is that since we have to go through multiple events to find if there is a link or not (utilizing closures for mutability), we cannot do simple event replacements and map directly onto the push_html-iteration. This does however mean that we don't need a tool like pulldown-cmark-to-cmark to export to CommonMark, and the time penalty should be minimal.