The problem appeared recently.
Images and links are not displayed correctly.
This was entirely my screw-up. Here's what happened.
This is how Markdown handles links:
The "Magic" step is the auto-linking – take anything that looks like a plain link, and put it between angle brackets, so that step 3 will turn it into real HTML links.
Before I made the change, step 2 only handled URLs that were preceded by a whitespace character, which is why the fairly common idea of putting a link in parentheses:
never worked as expected – an open parenthesis is not a whitespace character.
The change I made was to allow any non-word character before the URL instead. Which was a horribly stupid idea (and in fact, I had previously shied away from this change because of exactly this problem – but for some reason, this didn't enter my mind yesterday until all hell broke loose).
Imagine this Markdown source:
After step 1, the intermediate HTML looks like this:
Now comes step 2. Before my change, it wouldn't touch anything here, because the
Now comes step three (linebreak added for readability):
Then the HTML sanitizer removes the illegal "tag" from the first
and finally the tag balancer removes the two closing
– and that's what you saw.
So (except for just forgetting this issue despite having previously considered it), why didn't I realize this problem?
Well, the test post I played with while testing had no Markdown-syntax links, just bare URLs. So step 1 never did anything, and nothing broke.
I also ran the test suite in MarkdownSharp, and it didn't report any issues with the change either. Why? Because unfortunately, step 2 is a configurable option in MarkdownSharp, and turned off by default. And most tests run with the default options. And those few test cases that enable this option only test the auto-linking – they don't have any links for step 1 either.
Kevin backed my change out, since he felt that unbroken Markdown would be a nice thing to have, and I tend to agree with that.
This question is thus not completed at the moment, but it will be again after the next build. I've changed step 2 to require a URL to be preceded by a non-word character and neither by
And just to be sure, this time I have not only run the tests with the option on; I have also tested the change against a couple of thousand real-world questions and answers to make sure that the only differences in rendering are intended ones.
A fix for this has been deployed. It looks like some recent changes to the Markdown rendering pipeline went sideways.
Affected posts will display incorrect HTML until they're edited (as we cache the rendered Markdown)... which means I'm going to be poking a bunch of posts for the next hour or so.
Poking completed, all affected posts should have been corrected. If you see anything left over, let me know.