diff --git a/lib/rules_block/blockquote.js b/lib/rules_block/blockquote.js index a83c0df..326d353 100644 --- a/lib/rules_block/blockquote.js +++ b/lib/rules_block/blockquote.js @@ -10,8 +10,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) { pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine]; - if (pos > max) { return false; } - // check the block quote marker if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; } diff --git a/lib/rules_block/heading.js b/lib/rules_block/heading.js index f5ef6a2..4fe90f0 100644 --- a/lib/rules_block/heading.js +++ b/lib/rules_block/heading.js @@ -8,8 +8,6 @@ module.exports = function heading(state, startLine, endLine, silent) { pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine]; - if (pos >= max) { return false; } - ch = state.src.charCodeAt(pos); if (ch !== 0x23/* # */ || pos >= max) { return false; } diff --git a/lib/rules_block/hr.js b/lib/rules_block/hr.js index 2fbbc07..3b7db36 100644 --- a/lib/rules_block/hr.js +++ b/lib/rules_block/hr.js @@ -5,13 +5,9 @@ module.exports = function hr(state, startLine, endLine, silent) { var marker, cnt, ch, - pos = state.bMarks[startLine], + pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine]; - pos += state.tShift[startLine]; - - if (pos > max) { return false; } - marker = state.src.charCodeAt(pos++); // Check hr marker diff --git a/lib/rules_block/list.js b/lib/rules_block/list.js index 4ee6072..af18c4c 100644 --- a/lib/rules_block/list.js +++ b/lib/rules_block/list.js @@ -11,8 +11,6 @@ function skipBulletListMarker(state, startLine) { pos = state.bMarks[startLine] + state.tShift[startLine]; max = state.eMarks[startLine]; - if (pos >= max) { return -1; } - marker = state.src.charCodeAt(pos++); // Check bullet if (marker !== 0x2A/* * */ && @@ -36,6 +34,7 @@ function skipOrderedListMarker(state, startLine) { pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine]; + // List marker should have at least 2 chars (digit + dot) if (pos + 1 >= max) { return -1; } ch = state.src.charCodeAt(pos++); diff --git a/lib/rules_block/paragraph.js b/lib/rules_block/paragraph.js index 4f6c10e..dcfd893 100644 --- a/lib/rules_block/paragraph.js +++ b/lib/rules_block/paragraph.js @@ -34,26 +34,24 @@ module.exports = function paragraph(state, startLine/*, endLine*/) { content = state.getLines(startLine, nextLine, state.blkIndent, false).trim(); state.line = nextLine; - if (content.length) { - state.tokens.push({ - type: 'paragraph_open', - tight: false, - lines: [ startLine, state.line ], - level: state.level - }); - state.tokens.push({ - type: 'inline', - content: content, - level: state.level + 1, - lines: [ startLine, state.line ], - children: [] - }); - state.tokens.push({ - type: 'paragraph_close', - tight: false, - level: state.level - }); - } + state.tokens.push({ + type: 'paragraph_open', + tight: false, + lines: [ startLine, state.line ], + level: state.level + }); + state.tokens.push({ + type: 'inline', + content: content, + level: state.level + 1, + lines: [ startLine, state.line ], + children: [] + }); + state.tokens.push({ + type: 'paragraph_close', + tight: false, + level: state.level + }); return true; }; diff --git a/test/fixtures/markdown-it/commonmark_extras.txt b/test/fixtures/markdown-it/commonmark_extras.txt index 4e310e7..493bfb1 100644 --- a/test/fixtures/markdown-it/commonmark_extras.txt +++ b/test/fixtures/markdown-it/commonmark_extras.txt @@ -197,14 +197,13 @@ z") z">foo

. -Image coverage +Coverage. Image . ![test]( x ) .

test

. - . ![test][foo] @@ -212,7 +211,6 @@ Image coverage .

![test][foo]

. - . ![test][[[ @@ -220,3 +218,16 @@ Image coverage .

![test][[[

. +. +![test]( +. +

![test](

+. + + +Coverage. Link +. +[test]( +. +

[test](

+.