|
@ -4,6 +4,10 @@ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isEmpty = require('./helpers').isEmpty; |
|
|
|
|
|
var skipEmptyLines = require('./helpers').skipEmptyLines; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var rules = []; |
|
|
var rules = []; |
|
|
|
|
|
|
|
|
// `list` should be after `hr`, but before `heading`
|
|
|
// `list` should be after `hr`, but before `heading`
|
|
@ -113,7 +117,9 @@ LexerBlock.prototype.tokenize = function (state, startLine, endLine) { |
|
|
len = this.rules.length, |
|
|
len = this.rules.length, |
|
|
line = startLine; |
|
|
line = startLine; |
|
|
|
|
|
|
|
|
while (line < endLine) { |
|
|
for (;;) { |
|
|
|
|
|
line = state.line = skipEmptyLines(state, line, endLine); |
|
|
|
|
|
if (line >= endLine) { break; } |
|
|
|
|
|
|
|
|
// Try all possible rules.
|
|
|
// Try all possible rules.
|
|
|
// On success, rule should:
|
|
|
// On success, rule should:
|
|
@ -127,9 +133,18 @@ LexerBlock.prototype.tokenize = function (state, startLine, endLine) { |
|
|
if (ok) { break; } |
|
|
if (ok) { break; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (ok) { |
|
|
if (!ok) { throw new Error('No matching rules found'); } |
|
|
line = state.line; |
|
|
|
|
|
continue; |
|
|
if (line >= state.line) { |
|
|
|
|
|
throw new Error("Parser didn't update state.line"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
line = state.line; |
|
|
|
|
|
if (isEmpty(state, line)) { |
|
|
|
|
|
line++; |
|
|
|
|
|
|
|
|
|
|
|
// two empty lines should stop the parser
|
|
|
|
|
|
if (isEmpty(state, line + 1)) { break; } |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|