mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(options.omitExtraWLInCodeBlocks): fix for options.omitExtraWLInCodeBlocks only applying in gitHub flavoured code blocks
This commit is contained in:
parent
ddd6011df2
commit
e6f40e190c
|
@ -22,15 +22,21 @@ showdown.subParser('codeBlocks', function (text, options, globals) {
|
|||
|
||||
var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g;
|
||||
text = text.replace(pattern, function (wholeMatch, m1, m2) {
|
||||
var codeblock = m1, nextChar = m2;
|
||||
var codeblock = m1,
|
||||
nextChar = m2,
|
||||
end = '\n';
|
||||
|
||||
codeblock = showdown.subParser('outdent')(codeblock);
|
||||
codeblock = showdown.subParser('encodeCode')(codeblock);
|
||||
codeblock = showdown.subParser('detab')(codeblock);
|
||||
codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
|
||||
codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
|
||||
codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
|
||||
|
||||
codeblock = '<pre><code>' + codeblock + '\n</code></pre>';
|
||||
if (options.omitExtraWLInCodeBlocks) {
|
||||
end = '';
|
||||
}
|
||||
|
||||
codeblock = '<pre><code>' + codeblock + end + '</code></pre>';
|
||||
|
||||
return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user