Skip to content

Commit

Permalink
Always suffix indented code block with a newline
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin authored and rlidwka committed Jul 15, 2021
1 parent 13cdeb9 commit e5986bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules_block/code.js
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions test/misc.js
Expand Up @@ -182,6 +182,9 @@ describe('Misc', function () {

assert.strictEqual(md.render('123'), '<p>123</p>\n');
assert.strictEqual(md.render('123\n'), '<p>123</p>\n');

assert.strictEqual(md.render(' codeblock'), '<pre><code>codeblock\n</code></pre>\n');
assert.strictEqual(md.render(' codeblock\n'), '<pre><code>codeblock\n</code></pre>\n');
});

it('Should quickly exit on empty string', function () {
Expand Down

0 comments on commit e5986bb

Please sign in to comment.