Closed astroowen closed 1 month ago
Hey @astroowen, thank you for reporting this issue.
Implementing this as a plugin (example) was not the best idea.
This should be dealt with in mistune as plugin in the renderer, where the order and hierachy of the parsed elements matters. I will take care of it this week.
After implementing the wikilink as mistune plugin and running the tests I was reminded why I chose this workaround .. Wikilinks inside of a table didn't work, e.g.
| name | date | link |
| -------- | ---------- | -------------------- |
| John | 01/31/1996 | [[people/John]] |
| Mary | 10/08/2001 | [[Mary|people/Mary]] |
The [[Mary|people/Mary]]
wikilink breaks the "Mary" row.
I even wrote a test for that ... 😅
Will dig futher into this.
I'm running 2.6.1. Wikilinks are handled by the parser by converting them to the equivalent markdown link. But the parser is too eager and also performs this conversion inside code blocks (between backticks).
For example, in the markdown source I write
But on the page I see
Which is not what I wrote: the [[]] syntax becomes []() syntax. Then it's impossible to demonstrate the wikilink syntax. I expect the parsed markdown output to reflect verbatim what I put in code blocks.
Fortunately it looks (to me) like this parsing is not done by the mistune package but by these regexes in this plugin:
https://github.com/redimp/otterwiki/blob/67264121ab51b83b7e4164b49ba89cd380eae4c6/otterwiki/plugins.py#L46-L51
A naïve but fast way to fix this is just to modify the regexes to exclude strings starting with backticks. I'm not sure if there is some place in the rendering where code blocks are handled which could be modified to just not activate the plugin for that text - that would be a clearer solution, I think.