-
Notifications
You must be signed in to change notification settings - Fork 320
Description
I was trying to implement an extension that turns references denoted by a prefix character (@,#, or ~) into a link, and missing the means to do it. A PostProcessor won't do it, because I want the prefix characters to be escapable by backslash to take away their special meaning, and the info necessary for that doesn't survive into the AST. The Delimiter stuff isn't useful either, because we have no definite closing character.
The proper solution would be a sub-parser that is activated then the main parser sees the prefix character. This something that InlineParserImpl already does internally:
this.inlineParsers = new HashMap<>();
this.inlineParsers.put('\\', Collections.<InlineContentParser>singletonList(new BackslashInlineParser()));
this.inlineParsers.put('`', Collections.<InlineContentParser>singletonList(new BackticksInlineParser()));
this.inlineParsers.put('&', Collections.<InlineContentParser>singletonList(new EntityInlineParser()));
this.inlineParsers.put('<', Arrays.asList(new AutolinkInlineParser(), new HtmlInlineParser()));
but not only is InlineParserImpl in an internal package, but all relevant methods and fields are private as well, so I have no chance to use it even if I didn't care about backward compatibility.
I suggest opening up an official way of adding sub-parsers to the internal parser.