markdown-js icon indicating copy to clipboard operation
markdown-js copied to clipboard

wrong output

Open tallesl opened this issue 11 years ago • 5 comments

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.

tallesl avatar Jan 09 '14 01:01 tallesl

Looks like we have an overly greedy regex. This is reproducible in the latest code.

evilstreak avatar Jan 09 '14 10:01 evilstreak

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>

progrape avatar Sep 18 '14 07:09 progrape

I believe @jspauld tracked down the origin of this bug and found a fix. See the discussion on Thinklab.

dhimmel avatar Feb 18 '16 20:02 dhimmel

Yes I will submit a pull request here

jspauld avatar Feb 18 '16 20:02 jspauld

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.

jspauld avatar Feb 18 '16 21:02 jspauld