markdown-js
markdown-js copied to clipboard
wrong output
I'm getting the following wrong output:
> require('markdown').parse('[github.com/languages](https://github.com/languages) now redirects to [github.com/trending](https://github.com/trending "Trending repositories on GitHub today")')
'<p><a href="https://github.com/languages) now redirects to [github.com/trending](https://github.com/trending" title="Trending repositories on GitHub today">github.com/languages</a></p>'
Dunno what it is. The input syntax seems to be fine.
With version 0.5.0.
Looks like we have an overly greedy regex. This is reproducible in the latest code.
I'm also getting a wrong output like this:
var markdown = require( "markdown" ).markdown;
console.log( markdown.toHTML( "[http://github.com/aa_bb](http://github.com/aa_bb)" ) );
I want to output html like <p><a href="http://github.com/aa_bb">http://github.com/aa_bb</a></p>, but actually output <p>[http://github.com/aa<em>bb](http://github.com/aa</em>bb)</p>
I believe @jspauld tracked down the origin of this bug and found a fix. See the discussion on Thinklab.
Yes I will submit a pull request here
This bug no longer appears on Discourse which is based on markdown-js. I checked their code and they seem to have updated this line:
var m = text.match( /^\s*\([ \t]*([^"']*)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/ );
to this:
var m = text.match( /^\s*\([ \t]*([^"'\s]*)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/ );
I tried marking this change on this repo but the spaces_in_url test fails if I do so. I'll leave it to others to figure out the appropriate solution.