While reviewing https://stackoverflow.com/q/3139601/212218#3139749 I noticed that the URL that was posted as one of the answers looked weird to me:


I clicked on the edit link to see if the user had perhaps posted some broken HTML, but all I found was a bare URL:


Here's how the above URL renders currently:


(I'm assuming) it should look like this:


EDIT: I wonder if it has anything to do with the double underscore that is causing the word "leopard" to appear italicized?

Let's try that out by removing the double underscore:


Aha! That must be it.


It looks like the auto-linker passes in the URL as-is, the result of which is then fed to the method that handles bold/italics. This causes an <em> tag to appear in the href attribute of the link, the HTML sanitizer gets angry, and you end up with the mess that you see there.

The most direct fix seems to be to have the auto-linker do what the normal linker does and have the replace method do ml = escapeCharacters(ml, "*_") when inserting the URL in the preview, and the equivalent link = EscapeBoldItalic(link) in MarkdownSharp. I need to verify that this doesn't break anything else, but if it doesn't I'll submit patches later provided this isn't fixed before then.

I should add that with links that ugly it's much nicer if they have a proper descriptive text anyway, but the behaviour does seem buggy in either case.

Update: It seems that this was already because Jeff felt it was too much of an edge case, but I've gone ahead and made a fix for Pagedown anyway.

  • Does your fix get used in SO? The link to the commit in your answer is currently 404. – nhahtdh Feb 20 '13 at 5:07
  • Oh, whoops. But no, it's not used on SO. – Tim Stone Feb 20 '13 at 13:18