Browse Source

Fix nested elements inside lists

"# foo" should be parsed as "h1", not as a continuation
---
   -   test
       # foo
---
pull/14/head
Alex Kocharin 10 years ago
parent
commit
7a8899e501
  1. 3
      lib/lexer_block/blockquote.js
  2. 9
      lib/lexer_block/heading.js
  3. 3
      lib/lexer_block/hr.js
  4. 2
      lib/lexer_block/list.js
  5. 7
      lib/lexer_block/paragraph.js

3
lib/lexer_block/blockquote.js

@ -12,9 +12,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
pos = state.bMarks[startLine] + state.tShift[startLine],
max = state.eMarks[startLine];
// should not have > 3 leading spaces
if (state.tShift[startLine] > 3) { return false; }
if (pos > max) { return false; }
// check the block quote marker

9
lib/lexer_block/heading.js

@ -10,13 +10,8 @@ var skipCharsBack = require('../helpers').skipCharsBack;
module.exports = function heading(state, startLine, endLine, silent) {
var ch, level,
pos = state.bMarks[startLine],
max = state.eMarks[startLine],
offset = state.tShift[startLine];
if (offset > 3) { return false; }
pos += offset;
pos = state.bMarks[startLine] + state.tShift[startLine],
max = state.eMarks[startLine];
if (pos >= max) { return false; }

3
lib/lexer_block/hr.js

@ -11,9 +11,6 @@ module.exports = function hr(state, startLine, endLine, silent) {
pos = state.bMarks[startLine],
max = state.eMarks[startLine];
// should not have > 3 leading spaces
if (state.tShift[startLine] - state.blkIndent > 3) { return false; }
pos += state.tShift[startLine];
if (pos > max) { return false; }

2
lib/lexer_block/list.js

@ -12,8 +12,6 @@ var skipSpaces = require('../helpers').skipSpaces;
function skipBulletListMarker(state, startLine) {
var marker, pos, max;
if (state.tShift[startLine] - state.blkIndent > 3) { return -1; }
pos = state.bMarks[startLine] + state.tShift[startLine];
max = state.eMarks[startLine];

7
lib/lexer_block/paragraph.js

@ -15,7 +15,11 @@ module.exports = function paragraph(state, startLine/*, endLine*/) {
endLine = state.lineMax;
// jump line-by-line until empty one or EOF
while (nextLine < endLine && !isEmpty(state, nextLine)) {
for (; nextLine < endLine && !isEmpty(state, nextLine); nextLine++) {
// this would be a code block normally, but after paragraph
// it's considered a lazy continuation regardless of what's there
if (state.tShift[nextLine] - state.blkIndent > 3) { continue; }
// Some tags can terminate paragraph without empty line.
if (rules_named.fences(state, nextLine, endLine, true)) { break; }
if (rules_named.hr(state, nextLine, endLine, true)) { break; }
@ -27,7 +31,6 @@ module.exports = function paragraph(state, startLine/*, endLine*/) {
if (rules_named.table(state, nextLine, endLine, true)) { break; }
//if (rules_named.tag(state, nextLine, endLine, true)) { break; }
//if (rules_named.def(state, nextLine, endLine, true)) { break; }
nextLine++;
}
state.tokens.push({ type: 'paragraph_open' });

Loading…
Cancel
Save