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

two blank lines break the code block

Open ckcks12 opened this issue 7 years ago • 5 comments

original text

function foo() {
    console.log(this);
}
// below two blank lines cause a bug


using markdown

markdown.toHTML('```\n\
function foo() {\n\
    console.log(this);\n\
}\n\
// below two blank lines cause a bug\n\
\n\
\n\
```')

converted

"<p><code></code>`
function foo() {
    console.log(this);
}
// below two blank lines cause a bug</p>

<p><code></code>`</p>"

Is that a bug or my mistake?

ckcks12 avatar May 21 '17 19:05 ckcks12

not only trailing position but also anywhere the two blank lines exist the code block be broken ...

ckcks12 avatar May 21 '17 20:05 ckcks12

I have meet the same issue, without line breaks in code

nicecp avatar Jul 16 '17 09:07 nicecp

I have try to revise the output of markdown.toHTML() function. here the simple code:

    html.replace(/<code><\/code>\`(?=[^<])/g,'<code>');
    html.replace(/<code><\/code>\`(?=<)/g, '<\/code>');

clChenLiang avatar Mar 28 '18 08:03 clChenLiang

Of course there are more workarounds for this but we want it be fixed, not more cheats.

ckcks12 avatar Mar 28 '18 09:03 ckcks12

Perhaps we could start by writing a test that fails... I'll try to get to it. I share your pain - Tiddlywiki uses this library! Also worth checking out if a fork has this fixed.

icarito avatar May 12 '18 05:05 icarito