evilstreak / markdown-js

A Markdown parser for javascript
7.7k stars 863 forks source link

Links in parens break #38

Closed beatgammit closed 12 years ago

beatgammit commented 12 years ago

I have something like this:

Lorem ipsum (lorem ipsum) dolar sit amut.

However, the last closing paren is removed. I am getting something like this instead:

Lorem ipsum (lorem ipsum dolar sit amut.

Github does this correctly, as does dingus.

I tracked it down to markdown.js:823,

/^\[([\s\S]*?)\][ \t]*\([ \t]*(\S+)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/

This regex is greedily matching up to the last ).

ashb commented 12 years ago

Fixed last night in the other link bug. Output is now

Lorem ipsum (<a href="http://www.lipsum.com/)">lorem ipsum</a> dolar sit amut.</p>

which looks right now.

ashb commented 12 years ago

Gah that's clearly not. The end of the regex is in the wrong place.