Cannot backslash-escape left angle bracket < in links


(Kane York) #1

If I place a lone < in a link title, the remaining text on the line is removed.

Lorem [foo <link bar](//null) dolores becomes:

Lorem foo <link bar dolores

which is quite very wrong.

Attempting to use a \ to markdown-escape it did not work:
Lorem [foo \<link bar](//null) dolores becomes

Lorem foo <link bar dolores

If I try closing the tag:
Lorem [foo <link> bar](//null) dolores becomes

Lorem foo bar dolores

Using entities seems to work:
Lorem [foo &lt;link bar](//null) dolores

Lorem foo <link bar dolores

But that makes for a very ugly source view.


(Konrad Borowski) #2

In original Markdown, \< doesn’t mean &lt; (rather, it means \<). However, I could find prior art (GitHub Flavored Markdown), so perhaps that’s a good argument why \< should work like &lt;. The second argument would be that parsing it like \< doesn’t make any sense.


(Aahan Krish) #3

I’d consider this a bug as well.

Lorem [foo \<link bar](http://google.com) dolores should result in Lorem <a href="http://google.com">foo \<link bar</a> dolores, which means the end result will still be:

Lorem foo <link bar dolores

And that’s because you are using < instead of its HTML entity &lt;. But that’s not my point. Discourse is parsing the markdown to this:

Lorem <a href="http://google.com">foo \ dolores</a>

Therefore, it’s yet another (edge case) bug in the new parser. @eviltrout is it a good idea to ping you everytime there’s a bug in the parser, or are you going to find it anyway? (I mean, I don’t want to take it to a point where it gets irritating to you. :wink: )


(Robin Ward) #4

I’m not sure it’s valid markdown to put a < inside a link like that. I checked against PageDown on Stack Overflow and it has the same behaviour as us, so I don’t think it’s a regression in my parser.

This one seems really edge-casey, I might delay on it and see how many are frustrated by it. In the meantime, a workaround is to just use a regular link. Or a bbcode style link. Both will work!


(Jeff Atwood) #5

http://johnmacfarlane.net/babelmark2/?text=Lorem+[foo+<link+bar](%2F%2Fnull)+dolores

Consensus is this should produce

<p>Lorem <a href="//null">foo &lt;link bar</a> dolores</p>

(Jeff Atwood) #6

Looks correct to me now.


(Jeff Atwood) #7