|
| 1 | +diff --git a/index.js b/index.js |
| 2 | +index 85d89900d5fe575dd0c19430209fb1703b03554e..5fa68cc9a4bd2b21a7188bd263262fd9b1604ac6 100644 |
| 3 | +--- a/index.js |
| 4 | ++++ b/index.js |
| 5 | +@@ -145,7 +145,8 @@ module.exports = function multimd_table_plugin(md, options) { |
| 6 | + colspan, leftToken, |
| 7 | + rowspan, upTokens = [], |
| 8 | + tableLines, tgroupLines, |
| 9 | +- tag, text, range, r, c, b; |
| 10 | ++ tag, text, range, r, c, b, t, |
| 11 | ++ blockState; |
| 12 | + |
| 13 | + if (startLine + 2 > endLine) { return false; } |
| 14 | + |
| 15 | +@@ -315,18 +316,26 @@ module.exports = function multimd_table_plugin(md, options) { |
| 16 | + |
| 17 | + /* Multiline. Join the text and feed into markdown-it blockParser. */ |
| 18 | + if (options.multiline && trToken.meta.multiline && trToken.meta.mbounds) { |
| 19 | +- text = [ text.trimRight() ]; |
| 20 | ++ // Pad the text with empty lines to ensure the line number mapping is correct |
| 21 | ++ text = new Array(trToken.map[0]).fill('').concat([ text.trimRight() ]); |
| 22 | + for (b = 1; b < trToken.meta.mbounds.length; b++) { |
| 23 | + /* Line with N bounds has cells indexed from 0 to N-2 */ |
| 24 | + if (c > trToken.meta.mbounds[b].length - 2) { continue; } |
| 25 | + range = [ trToken.meta.mbounds[b][c] + 1, trToken.meta.mbounds[b][c + 1] ]; |
| 26 | + text.push(state.src.slice.apply(state.src, range).trimRight()); |
| 27 | + } |
| 28 | +- state.md.block.parse(text.join('\n'), state.md, state.env, state.tokens); |
| 29 | ++ blockState = new state.md.block.State(text.join('\n'), state.md, state.env, []); |
| 30 | ++ blockState.level = trToken.level + 1; |
| 31 | ++ // Start tokenizing from the actual content (trToken.map[0]) |
| 32 | ++ state.md.block.tokenize(blockState, trToken.map[0], blockState.lineMax); |
| 33 | ++ for (t = 0; t < blockState.tokens.length; t++) { |
| 34 | ++ state.tokens.push(blockState.tokens[t]); |
| 35 | ++ } |
| 36 | + } else { |
| 37 | + token = state.push('inline', '', 0); |
| 38 | + token.content = text.trim(); |
| 39 | + token.map = trToken.map; |
| 40 | ++ token.level = trToken.level + 1; |
| 41 | + token.children = []; |
| 42 | + } |
| 43 | + |
0 commit comments