Browse Source

listMode -> parentType

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
07a5bf5c7f
  1. 2
      lib/parser_block.js
  2. 8
      lib/rules_block/blockquote.js
  3. 8
      lib/rules_block/list.js
  4. 4
      lib/rules_block/state_block.js

2
lib/parser_block.js

@ -98,7 +98,7 @@ ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
line++;
// two empty lines should stop the parser in list mode
if (line < endLine && state.listMode && state.isEmpty(line)) { break; }
if (line < endLine && state.parentType === 'list' && state.isEmpty(line)) { break; }
state.line = line;
}
}

8
lib/rules_block/blockquote.js

@ -4,7 +4,7 @@
module.exports = function blockquote(state, startLine, endLine, silent) {
var nextLine, lastLineEmpty, oldTShift, oldBMarks, oldIndent, oldListMode,
var nextLine, lastLineEmpty, oldTShift, oldBMarks, oldIndent, oldParentType,
terminatorRules = state.parser._rulesBlockquoteTerm, i, l, terminate,
pos = state.bMarks[startLine] + state.tShift[startLine],
max = state.eMarks[startLine];
@ -103,12 +103,12 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
state.tShift[nextLine] = -1337;
}
oldListMode = state.listMode;
state.listMode = false;
oldParentType = state.parentType;
state.parentType = 'blockquote';
state.tokens.push({ type: 'blockquote_open', level: state.level++ });
state.parser.tokenize(state, startLine, nextLine);
state.tokens.push({ type: 'blockquote_close', level: --state.level });
state.listMode = oldListMode;
state.parentType = oldParentType;
// Restore original tShift; this might not be necessary since the parser
// has already been here, but just to make sure we can do that.

8
lib/rules_block/list.js

@ -75,7 +75,7 @@ module.exports = function list(state, startLine, endLine, silent) {
oldTShift,
oldIndent,
oldTight,
oldListMode,
oldParentType,
start,
posAfterMarker,
max,
@ -165,11 +165,11 @@ module.exports = function list(state, startLine, endLine, silent) {
oldIndent = state.blkIndent;
oldTight = state.tight;
oldTShift = state.tShift[startLine];
oldListMode = state.listMode;
oldParentType = state.parentType;
state.tShift[startLine] = contentStart - state.bMarks[startLine];
state.blkIndent = indent;
state.tight = true;
state.listMode = true;
state.parentType = 'list';
state.parser.tokenize(state, startLine, endLine, true);
@ -184,7 +184,7 @@ module.exports = function list(state, startLine, endLine, silent) {
state.blkIndent = oldIndent;
state.tShift[startLine] = oldTShift;
state.tight = oldTight;
state.listMode = oldListMode;
state.parentType = oldParentType;
state.tokens.push({ type: 'list_item_close', level: --state.level });

4
lib/rules_block/state_block.js

@ -35,8 +35,8 @@ function StateBlock(src, parser, tokens, options, env) {
// (for example, if we are in list)
this.line = 0; // line index in src
this.lineMax = 0; // lines count
this.tight = false; // loose/tight mode for lists
this.listMode = false; // if true, block parser stops on two newlines
this.tight = false; // loose/tight mode for lists
this.parentType = 'root'; // if `list`, block parser stops on two newlines
this.level = 0;

Loading…
Cancel
Save