mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Opening square bracket is ignored as OpeningCharacter #729
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ridercz on GitHub (Mar 12, 2025).
I'm trying to write extension, which will convert markup
[#something]to a link to an item with namesomething, ie.<a href="#something">name-of-something-got-from-lookup</a>.My trouble is that when I define
OpeningCharacters = ['['];in my class derived fromInlineParser, the parser is not invoked. If I use any other character (like#), it work just fine.The minimal example is:
The
Matchmethod is never called, the exception is never thrown, even when the source document contains[#something].For now I solved the problem by using
#as my opening character, but then i have extra[in front of the link, ie.[<a href="#something">name-of-something-got-from-lookup</a>@MihaZupan commented on GitHub (Mar 12, 2025):
Are you inserting your parser before the
LinkInlineParserin the inline parser list?@ridercz commented on GitHub (Mar 12, 2025):
@MihaZupan no, but from other documentation I thought that multiple parsers can share the same trigger character?
@ridercz commented on GitHub (Mar 12, 2025):
@MihaZupan when I positioned it before the
LinkInlineParser, it solved my problem, thanks.@MihaZupan commented on GitHub (Mar 12, 2025):
They can share it, but if one parser says it matched that location then others won't be attempted. So order matters there.
Alternatiely if you're just trying to replace the URLs based on some lookup, consider post-processing the
MarkdownDocumentinstead of implementing a parser, it might be simpler.