Closed andrei-akopian closed 5 months ago
Oof, yeah. I see the issue you're describing.
Bear uses Mistune under the hood for markdown rendering, and this seems to be a limitation with it. I'll see if I can do something about it on the renderer wrapper, otherwise I may have to dig into Mistune itself.
I found the bug report on Mistune
https://github.com/lepture/mistune/issues/355
Their entire bug tracker is discussing odd formatting behavior and what to do with it. If you add a workaround right now, you will have to remove it one Mistuned fixes stuff on their end. Up to you.
Another "solution" I found is to replace parentheses in URLs with their encodings ( = %28
and ) = %29
. The URLs still work at least for Wikipedia. Maybe it could save Markdown from standardization issues...
I've pushed a fix. It pre-processes markdown links with parentheses and escapes them before going through the renderer. It's not idea, but it work. Let me know if you run into any issues with it, otherwise you can close the issue if you're happy.
Ah, just seeing your comment now. You can I came to the same solution :)
Also, this will still work even if mistune fixes the issue since it's a pre-processing step. Once they fix the issue I can go remove it, but it won't break anything.
Thanks, are you going to close the issue now?
Also, I think you left a print statement in your commit.
Update: Mistune decided not to fix it in favor of supporting "traditional markdown". The parentheses support was supposedly normalized by some other library.
https://github.com/lepture/mistune/issues/355#issuecomment-2230920270
Their "solution" is have the user wrap the link in angle brackets. ([Example](<https://example.com/(Example)>)
)
Idk, odd decision that leaves more trouble than it would fix, but whatever.
If a link contains parenthesis, like many wikipedia articles do such as
https://en.wikipedia.org/wiki/Python_(programming_language)
. If I try to write a hyperlink in markdown using the[ text ] ( link )
notation. Most markdown editors (including Github Issues) will create: PythonHowever bearblog disregards parenthesis that belong to the link itself:
I like [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) the programing language.
Notice the extra parenthesis) and the embedded link is missing a parenthesis and will thus redirect to a "Page Not Found."
I assume the underlying code of the bearblog converter does the following:
But there should be a step in between there: account for any opening parenthesis in the link.
Now you could create a debate about whether to change the hyperlink converter:
\)
\(