|
@ -12,7 +12,7 @@ function lineMatch(state, line, reg) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function table(state, startLine, endLine, silent) { |
|
|
module.exports = function table(state, startLine, endLine, silent) { |
|
|
var ch, firstLineMatch, secondLineMatch, i, subState, nextLine, m, rows, |
|
|
var ch, firstLineMatch, secondLineMatch, i, nextLine, m, rows, |
|
|
aligns, t; |
|
|
aligns, t; |
|
|
|
|
|
|
|
|
// should have at least three lines
|
|
|
// should have at least three lines
|
|
@ -48,12 +48,14 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'table_open' }); |
|
|
state.tokens.push({ type: 'table_open' }); |
|
|
state.tokens.push({ type: 'tr_open' }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'tr_open' }); |
|
|
for (i = 0; i < rows.length; i++) { |
|
|
for (i = 0; i < rows.length; i++) { |
|
|
state.tokens.push({ type: 'th_open', align: aligns[i] }); |
|
|
state.tokens.push({ type: 'th_open', align: aligns[i] }); |
|
|
subState = state.clone(rows[i].trim()); |
|
|
state.tokens.push({ |
|
|
state.lexerInline.tokenize(subState, subState.src); |
|
|
type: 'inline', |
|
|
|
|
|
content: rows[i].trim() |
|
|
|
|
|
}); |
|
|
state.tokens.push({ type: 'th_close' }); |
|
|
state.tokens.push({ type: 'th_close' }); |
|
|
} |
|
|
} |
|
|
state.tokens.push({ type: 'tr_close' }); |
|
|
state.tokens.push({ type: 'tr_close' }); |
|
@ -66,8 +68,10 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
state.tokens.push({ type: 'tr_open' }); |
|
|
state.tokens.push({ type: 'tr_open' }); |
|
|
for (i = 0; i < rows.length; i++) { |
|
|
for (i = 0; i < rows.length; i++) { |
|
|
state.tokens.push({ type: 'td_open', align: aligns[i] }); |
|
|
state.tokens.push({ type: 'td_open', align: aligns[i] }); |
|
|
subState = state.clone(rows[i].replace(/^\|? *| *\|?$/g, '')); |
|
|
state.tokens.push({ |
|
|
state.lexerInline.tokenize(subState, subState.src); |
|
|
type: 'inline', |
|
|
|
|
|
content: rows[i].replace(/^\|? *| *\|?$/g, '') |
|
|
|
|
|
}); |
|
|
state.tokens.push({ type: 'td_close' }); |
|
|
state.tokens.push({ type: 'td_close' }); |
|
|
} |
|
|
} |
|
|
state.tokens.push({ type: 'tr_close' }); |
|
|
state.tokens.push({ type: 'tr_close' }); |
|
|