|
|
@ -68,13 +68,16 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
|
var ch, lineText, pos, i, nextLine, columns, columnCount, token, |
|
|
|
aligns, t, tableLines, tbodyLines; |
|
|
|
|
|
|
|
// should have at least three lines
|
|
|
|
// should have at least two lines
|
|
|
|
if (startLine + 2 > endLine) { return false; } |
|
|
|
|
|
|
|
nextLine = startLine + 1; |
|
|
|
|
|
|
|
if (state.sCount[nextLine] < state.blkIndent) { return false; } |
|
|
|
|
|
|
|
// if it's indented more than 3 spaces, it should be a code block
|
|
|
|
if (state.sCount[nextLine] - state.blkIndent >= 4) { return false; } |
|
|
|
|
|
|
|
// first character of the second line should be '|', '-', ':',
|
|
|
|
// and no other characters are allowed but spaces;
|
|
|
|
// basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
|
|
|
@ -121,6 +124,7 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
|
|
|
|
|
lineText = getLine(state, startLine).trim(); |
|
|
|
if (lineText.indexOf('|') === -1) { return false; } |
|
|
|
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; } |
|
|
|
columns = escapedSplit(lineText.replace(/^\||\|$/g, '')); |
|
|
|
|
|
|
|
// header row will define an amount of columns in the entire table,
|
|
|
@ -163,12 +167,10 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
|
for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { |
|
|
|
if (state.sCount[nextLine] < state.blkIndent) { break; } |
|
|
|
|
|
|
|
lineText = getLine(state, nextLine); |
|
|
|
lineText = getLine(state, nextLine).trim(); |
|
|
|
if (lineText.indexOf('|') === -1) { break; } |
|
|
|
|
|
|
|
// keep spaces at beginning of line to indicate an empty first cell, but
|
|
|
|
// strip trailing whitespace
|
|
|
|
columns = escapedSplit(lineText.replace(/^\||\|\s*$/g, '')); |
|
|
|
if (state.sCount[nextLine] - state.blkIndent >= 4) { break; } |
|
|
|
columns = escapedSplit(lineText.replace(/^\||\|$/g, '')); |
|
|
|
|
|
|
|
token = state.push('tr_open', 'tr', 1); |
|
|
|
for (i = 0; i < columnCount; i++) { |
|
|
|