Duplicate spans with extra opening brackets
With no plugins except markdown-it-bracketed-spans enabled, the source string
[[b]{}
renders as
<p><span>b</span>[<span>b</span>{}</p>
whereas I would expect
<p>[<span>b</span>{}</p>
the content inside the intended bracketed span is duplicated before it.
With markdown-it-attrs included as well, you can observe the following minimal example:
[[b]{.c}
renders as
<p><span>b</span>[<span class="c">b</span></p>
I've tried for a little bit to debug this, but I just don't know a lot about markdown-it internals.
That's seems indeed a weird behaviour... not sure it's easily fixable though... it's been some time since I've been hacking on this :-)
I just don't know a lot about
markdown-itinternals.
see https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md
Pretty sure the problem is that we go into this if, which says we "probably" found a span... but ideally we would verify this some more inside the if...
I think I originally mostly copy-pasted, then adjusted markdown-it's link parser, which has this line saying:
We found the end of the link, and know for a fact it's a valid link;
but I'm not sure how they got that additional information at that point 🤷