|
|
@ -2,6 +2,8 @@ |
|
|
|
|
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var isSpace = require('../common/utils').isSpace; |
|
|
|
|
|
|
|
|
|
|
|
function getLine(state, line) { |
|
|
|
var pos = state.bMarks[line] + state.blkIndent, |
|
|
@ -64,16 +66,25 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
|
|
|
|
|
if (state.sCount[nextLine] < state.blkIndent) { return false; } |
|
|
|
|
|
|
|
// first character of the second line should be '|' or '-'
|
|
|
|
// first character of the second line should be '|', '-', ':',
|
|
|
|
// and no other characters are allowed but spaces;
|
|
|
|
// basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
|
|
|
|
|
|
|
|
pos = state.bMarks[nextLine] + state.tShift[nextLine]; |
|
|
|
if (pos >= state.eMarks[nextLine]) { return false; } |
|
|
|
|
|
|
|
ch = state.src.charCodeAt(pos); |
|
|
|
ch = state.src.charCodeAt(pos++); |
|
|
|
if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; } |
|
|
|
|
|
|
|
while (pos < state.eMarks[nextLine]) { |
|
|
|
ch = state.src.charCodeAt(pos); |
|
|
|
|
|
|
|
if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */ && !isSpace(ch)) { return false; } |
|
|
|
|
|
|
|
pos++; |
|
|
|
} |
|
|
|
|
|
|
|
lineText = getLine(state, startLine + 1); |
|
|
|
if (!/^[-:| ]+$/.test(lineText)) { return false; } |
|
|
|
|
|
|
|
columns = lineText.split('|'); |
|
|
|
aligns = []; |
|
|
|