So this is a conflict between tags (which are not Markdown syntax) and standard Markdown syntax.
Note that Markdown links allow a space between the label and the reference:
[link] [1]
[1]: http://example.com
which renders as1:
link
And, as Markdown parses left-to-right, the Markdown parser sees the tag followed by a link and assumes the tag is the first half of a reference style link. However, as no reference matches, then Markdown ignores the reference link and continues after the end of the reference. Of course, what Markdown say as a reference was actually intended to be the label of the link. So it starts back up with the actual reference, which does exist. And as Markdown allows for single reference style links (the label and reference is one and the same), it sees that reference as a link and processes it.
The point is that from a Markdown perspective, this is totally expected behavior. Thus the suggestion to escape the tag. Escaping the tag causes Markdown to not see it as part of a link (two spaces accomplish the same thing). The Markdown parser then picks up after the tag and now correctly pairs the label and reference parts of the link. And with the escape characters removed by Markdown, the postprocessor can recognize it as a tag and handle it appropriately.
So, the question is: how can SO fix this so that Markdown does not incorrectly recognize a tag as part of a link? I see a few options, none of which are great:
- Change the syntax for marking up tags.
- Alter the Markdown parser in some way:
- Remove the allowance for a space between label and reference.
- Extend the markdown parser to natively parse tags.
- Some other backward-incompatable change I haven't thought of.
1 Weirdly, the space between label and reference does not work within a quoteblock. In that case, it is not recognized as a link. Thus, I did not use a quoteblock above.