Add support for WikiLinks
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:
](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.