|
@ -4,7 +4,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function lineMatch(state, line, reg) { |
|
|
function lineMatch(state, line, reg) { |
|
|
var pos = state.bMarks[line], |
|
|
var pos = state.bMarks[line] + state.blkIndent, |
|
|
max = state.eMarks[line]; |
|
|
max = state.eMarks[line]; |
|
|
|
|
|
|
|
|
return state.src.substr(pos, max - pos).match(reg); |
|
|
return state.src.substr(pos, max - pos).match(reg); |
|
@ -18,6 +18,9 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
// should have at least three lines
|
|
|
// should have at least three lines
|
|
|
if (startLine + 2 > endLine) { return false; } |
|
|
if (startLine + 2 > endLine) { return false; } |
|
|
|
|
|
|
|
|
|
|
|
if (state.tShift[startLine + 1] < state.blkIndent) { return false; } |
|
|
|
|
|
if (state.bqMarks[startLine + 1] < state.bqLevel) { return false; } |
|
|
|
|
|
|
|
|
// first character of the second line should be '|' or '-'
|
|
|
// first character of the second line should be '|' or '-'
|
|
|
ch = state.src.charCodeAt(state.bMarks[startLine + 1] |
|
|
ch = state.src.charCodeAt(state.bMarks[startLine + 1] |
|
|
+ state.tShift[startLine + 1]); |
|
|
+ state.tShift[startLine + 1]); |
|
@ -31,9 +34,9 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
aligns = []; |
|
|
aligns = []; |
|
|
for (i = 0; i < rows.length; i++) { |
|
|
for (i = 0; i < rows.length; i++) { |
|
|
t = rows[i].trim(); |
|
|
t = rows[i].trim(); |
|
|
if (t[t.length - 1] === ':') { |
|
|
if (t.charCodeAt(t.length - 1) === 0x3A/* : */) { |
|
|
aligns[i] = t[0] === ':' ? 'center' : 'right'; |
|
|
aligns[i] = t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right'; |
|
|
} else if (t[0] === ':') { |
|
|
} else if (t.charCodeAt(0) === 0x3A/* : */) { |
|
|
aligns[i] = 'left'; |
|
|
aligns[i] = 'left'; |
|
|
} else { |
|
|
} else { |
|
|
aligns[i] = ''; |
|
|
aligns[i] = ''; |
|
@ -65,6 +68,9 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
state.tokens.push({ type: 'tbody_open', level: state.level++ }); |
|
|
state.tokens.push({ type: 'tbody_open', level: state.level++ }); |
|
|
|
|
|
|
|
|
for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { |
|
|
for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { |
|
|
|
|
|
if (state.tShift[nextLine] < state.blkIndent) { break; } |
|
|
|
|
|
if (state.bqMarks[nextLine] < state.bqLevel) { break; } |
|
|
|
|
|
|
|
|
m = lineMatch(state, nextLine, /^ *\|?(.*?\|.*?)\|? *$/); |
|
|
m = lineMatch(state, nextLine, /^ *\|?(.*?\|.*?)\|? *$/); |
|
|
if (!m) { break; } |
|
|
if (!m) { break; } |
|
|
rows = m[1].split('|'); |
|
|
rows = m[1].split('|'); |
|
|