I am close to having a parser that is ~99% common mark and GFM compliant, but I am hitting one case that is giving me trouble.
Based on the algorithm at the bottom of the specification:
If we have a link (and not an image), we also set all `[` delimiters before the opening delimiter to *inactive* . (This will prevent us from getting links within links.)
Based on my implementation of that algorithm,
[foo](uri1) is parsed normally. As part of that parsing, following that above guidance, the second
[ in that example is then marked as inactive. Therefore, when the next ‘]’ is hit, that skips over the “just marked” ‘[’ and gets pairs with the '![`. After that processing, the HTML produced becomes:
<p><img src="uri2" alt="foo" />](uri3)</p>
Is there something wrong with the algorithm?
Note, it looks like this was reported in The behaviour of alt text in image links is confusing but there are no comments about it.