|
@ -8,34 +8,34 @@ var skipChars = require('../helpers').skipChars; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function lheading(state, startLine, endLine, silent) { |
|
|
module.exports = function lheading(state, startLine, endLine, silent) { |
|
|
var marker, pos, mem, max, |
|
|
var marker, pos, max, |
|
|
next = startLine + 1; |
|
|
next = startLine + 1; |
|
|
|
|
|
|
|
|
if (next >= state.lineMax) { return false; } |
|
|
if (next >= state.lineMax) { return false; } |
|
|
|
|
|
|
|
|
// Scan next line
|
|
|
// Scan next line
|
|
|
|
|
|
if (state.tShift[next] > 3) { return false; } |
|
|
|
|
|
|
|
|
pos = state.bMarks[next] + state.tShift[next]; |
|
|
pos = state.bMarks[next] + state.tShift[next]; |
|
|
max = state.eMarks[next]; |
|
|
max = state.eMarks[next]; |
|
|
|
|
|
|
|
|
if (pos + 3 > max) { return false; } |
|
|
|
|
|
|
|
|
|
|
|
marker = state.src.charCodeAt(pos); |
|
|
marker = state.src.charCodeAt(pos); |
|
|
|
|
|
|
|
|
if (marker !== 0x2D/* - */ && marker !== 0x3D/* = */) { return false; } |
|
|
if (marker !== 0x2D/* - */ && marker !== 0x3D/* = */) { return false; } |
|
|
|
|
|
|
|
|
mem = pos; |
|
|
|
|
|
pos = skipChars(state, pos, marker); |
|
|
pos = skipChars(state, pos, marker); |
|
|
|
|
|
|
|
|
if (pos - mem < 3) { return false; } |
|
|
|
|
|
|
|
|
|
|
|
pos = skipSpaces(state, pos); |
|
|
pos = skipSpaces(state, pos); |
|
|
|
|
|
|
|
|
if (pos < max) { return false; } |
|
|
if (pos < max) { return false; } |
|
|
|
|
|
|
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
|
|
|
|
pos = state.bMarks[startLine] + state.tShift[startLine]; |
|
|
|
|
|
max = skipChars(state, state.eMarks[startLine], 0x20/* space */, pos); |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'heading_open', level: marker === 0x3D/* = */ ? 1 : 2 }); |
|
|
state.tokens.push({ type: 'heading_open', level: marker === 0x3D/* = */ ? 1 : 2 }); |
|
|
state.lexerInline.tokenize(state, state.bMarks[startLine], state.eMarks[startLine]); |
|
|
state.lexerInline.tokenize(state, pos, max); |
|
|
state.tokens.push({ type: 'heading_close', level: marker === 0x3D/* = */ ? 1 : 2 }); |
|
|
state.tokens.push({ type: 'heading_close', level: marker === 0x3D/* = */ ? 1 : 2 }); |
|
|
|
|
|
|
|
|
state.line = next + 1; |
|
|
state.line = next + 1; |
|
|