From e5986bb7cca20ac95dc81e4741c08949bf01bb77 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Mon, 12 Jul 2021 12:57:10 +0300 Subject: [PATCH] Always suffix indented code block with a newline --- lib/rules_block/code.js | 2 +- test/misc.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rules_block/code.js b/lib/rules_block/code.js index a83db116f..018e019fb 100644 --- a/lib/rules_block/code.js +++ b/lib/rules_block/code.js @@ -27,7 +27,7 @@ module.exports = function code(state, startLine, endLine/*, silent*/) { state.line = last; token = state.push('code_block', 'code', 0); - token.content = state.getLines(startLine, last, 4 + state.blkIndent, true); + token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\n'; token.map = [ startLine, state.line ]; return true; diff --git a/test/misc.js b/test/misc.js index e71ad3583..2f8712eb4 100644 --- a/test/misc.js +++ b/test/misc.js @@ -182,6 +182,9 @@ describe('Misc', function () { assert.strictEqual(md.render('123'), '
123
\n'); assert.strictEqual(md.render('123\n'), '123
\n'); + + assert.strictEqual(md.render(' codeblock'), 'codeblock\n
\n');
+ assert.strictEqual(md.render(' codeblock\n'), 'codeblock\n
\n');
});
it('Should quickly exit on empty string', function () {