I believe this is because the inline_rules for [ and ] that go into p.inline_parser.inline_parsers are identical for LinkRule and ImageRule (except that ImageRule also triggers on !):
My understanding of the parser is that parse_open_bracket will trigger anyway, because once it has been added to p.inline_parser.inline_parsers, it doesn't know whether it was added by LinkRule or ImageRule.
For an MWE, setting up the parser as follows to remove LinkRule (and it's associated inline_rules):
using CommonMark
p = Parser()
rules = filter(r -> !isa(r, LinkRule), p.rules)
disable!(p, copy(p.rules))
enable!(p, rules)
n = p("![a](b)\n\n[x](y)")
To be fair, I am not sure whether it even makes sense to disable one and not another. But if it doesn't, maybe it would make sense to merge them into a single rule?
I believe this is because the
inline_rule
s for[
and]
that go intop.inline_parser.inline_parsers
are identical forLinkRule
andImageRule
(except thatImageRule
also triggers on!
):https://github.com/MichaelHatherly/CommonMark.jl/blob/287e39ae128e80a6647d2d9762bf22040adffea1/src/parsers/inlines/links.jl#L271-L275
My understanding of the parser is that
parse_open_bracket
will trigger anyway, because once it has been added top.inline_parser.inline_parsers
, it doesn't know whether it was added byLinkRule
orImageRule
.For an MWE, setting up the parser as follows to remove
LinkRule
(and it's associatedinline_rule
s):The resulting AST still has the
Link
nodes: