Opening square bracket is ignored as OpeningCharacter #726

Open
opened 2026-01-29 14:43:58 +00:00 by claunia · 0 comments
Owner

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 name something, ie. <a href="#something">name-of-something-got-from-lookup</a>.

My trouble is that when I define OpeningCharacters = ['[']; in my class derived from InlineParser, the parser is not invoked. If I use any other character (like #), it work just fine.

The minimal example is:

public class StepLinkInlineParser : InlineParser {

    public StepLinkInlineParser() {
        this.OpeningCharacters = ['['];
    }

    public override bool Match(InlineProcessor processor, ref StringSlice slice) {
        throw new NotImplementedException();
    }

}

The Match method 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>

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 name `something`, ie. `<a href="#something">name-of-something-got-from-lookup</a>`. My trouble is that when I define `OpeningCharacters = ['['];` in my class derived from `InlineParser`, the parser is not invoked. If I use any other character (like `#`), it work just fine. The minimal example is: ```csharp public class StepLinkInlineParser : InlineParser { public StepLinkInlineParser() { this.OpeningCharacters = ['[']; } public override bool Match(InlineProcessor processor, ref StringSlice slice) { throw new NotImplementedException(); } } ``` The `Match` method 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>`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#726