markdown-js
markdown-js copied to clipboard
two blank lines break the code block
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?
not only trailing position but also anywhere the two blank lines exist the code block be broken ...
I have meet the same issue, without line breaks in code
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>');
Of course there are more workarounds for this but we want it be fixed, not more cheats.
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.