Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WikiLinks #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

amotta
Copy link

@amotta amotta commented Jul 2, 2023

Dear Alexis

I would like to use your excellent racket-commonmark library to parse and process notes taken with Obsidian. Obsidian generates CommonMark, with some custom syntax. Most importantly, Obsidian makes heavy use of WikiLinks, such as [[link]] and [[link|link with custom label]].

The commit in this pull request introduces

  • current-parse-wikilinks?, a parameter to enable the parsing of WikiLinks (with default value #f), and
  • wikilink, a struct corresponding to the new WikiLink inline content type.

I am not aware of a formal definition of WikiLinks, and parsing of WikiLinks differs substantially across implementations. Here, I have attempted to follow the behavior of MediaWiki, arguably the most widely-used wiki engine. (See, for example, the note on nested WikiLinks in inline.rkt.)

Importantly, enabling WikiLink parsing breaks conformance with the CommonMark spec! The following four conformance tests for CommonMark 0.30 fail when WikiLink parsing is enabled:

  • Example 519: ![[[foo](uri1)](uri2)](uri3)\n
  • Example 547: [[[foo]]]\n\n[[[foo]]]: /url\n
  • Example 558: [[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n
  • Example 589: ![[foo]]\n\n[[foo]]: /url \"title\"\n

Thus, I fully understand if you're not interested in this pull request.

amotta added 3 commits July 2, 2023 18:02
This commit adds support for parsing "WikiLinks". Specifically, it
introduces `current-parse-wikilinks?`, a parameter to enable the
parsing of "internal links" and "piped links" as defined by MediaWiki.

See https://www.mediawiki.org/wiki/Help:Links
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant