|
@ -47,36 +47,37 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
if (aligns.length !== rows.length) { return false; } |
|
|
if (aligns.length !== rows.length) { return false; } |
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'table_open' }); |
|
|
state.tokens.push({ type: 'table_open', level: state.level++ }); |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'tr_open' }); |
|
|
state.tokens.push({ type: 'tr_open', level: state.level++ }); |
|
|
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], level: state.level++ }); |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'inline', |
|
|
type: 'inline', |
|
|
content: rows[i].trim() |
|
|
content: rows[i].trim(), |
|
|
|
|
|
level: state.level |
|
|
}); |
|
|
}); |
|
|
state.tokens.push({ type: 'th_close' }); |
|
|
state.tokens.push({ type: 'th_close', level: --state.level }); |
|
|
} |
|
|
} |
|
|
state.tokens.push({ type: 'tr_close' }); |
|
|
state.tokens.push({ type: 'tr_close', level: --state.level }); |
|
|
|
|
|
|
|
|
for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { |
|
|
for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { |
|
|
m = lineMatch(state, nextLine, /^ *\|?(.*?\|.*?)\|? *$/); |
|
|
m = lineMatch(state, nextLine, /^ *\|?(.*?\|.*?)\|? *$/); |
|
|
if (!m) { break; } |
|
|
if (!m) { break; } |
|
|
rows = m[1].split('|'); |
|
|
rows = m[1].split('|'); |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'tr_open' }); |
|
|
state.tokens.push({ type: 'tr_open', level: state.level++ }); |
|
|
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], level: state.level++ }); |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'inline', |
|
|
type: 'inline', |
|
|
content: rows[i].replace(/^\|? *| *\|?$/g, '') |
|
|
content: rows[i].replace(/^\|? *| *\|?$/g, '') |
|
|
}); |
|
|
}); |
|
|
state.tokens.push({ type: 'td_close' }); |
|
|
state.tokens.push({ type: 'td_close', level: --state.level }); |
|
|
} |
|
|
} |
|
|
state.tokens.push({ type: 'tr_close' }); |
|
|
state.tokens.push({ type: 'tr_close', level: --state.level }); |
|
|
} |
|
|
} |
|
|
state.tokens.push({ type: 'table_close' }); |
|
|
state.tokens.push({ type: 'table_close', level: --state.level }); |
|
|
|
|
|
|
|
|
state.line = nextLine; |
|
|
state.line = nextLine; |
|
|
return true; |
|
|
return true; |
|
|