From 20e134bcb47271f1300acb6316111154c9bc6e4b Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Fri, 25 Sep 2020 17:26:04 +0300 Subject: [PATCH] Fix mappings for table rows - `table`, `tbody`, `tr` now have mapping - `th`, `td`, `inline` in tables do not have it close https://github.com/markdown-it/markdown-it/issues/705 --- CHANGELOG.md | 4 ++++ lib/rules_block/table.js | 8 +++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75f7edaed..388da05b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added 3rd argument to `highlight(code, lang, attrs)`, #626. - Rewrite tables according to latest GFM spec, #697. +### Fixed +- Fix mappings for table rows. `table`, `tbody`, `tr` now have mapping, + `th`, `td`, `inline` in tables do not have it, #705. + ## [11.0.1] - 2020-09-14 ### Fixed diff --git a/lib/rules_block/table.js b/lib/rules_block/table.js index c46d0c181..44895fe12 100644 --- a/lib/rules_block/table.js +++ b/lib/rules_block/table.js @@ -140,14 +140,12 @@ module.exports = function table(state, startLine, endLine, silent) { for (i = 0; i < columns.length; i++) { token = state.push('th_open', 'th', 1); - token.map = [ startLine, startLine + 1 ]; if (aligns[i]) { token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ]; } token = state.push('inline', '', 0); token.content = columns[i].trim(); - token.map = [ startLine, startLine + 1 ]; token.children = []; token = state.push('th_close', 'th', -1); @@ -180,16 +178,16 @@ module.exports = function table(state, startLine, endLine, silent) { token.map = tbodyLines = [ startLine + 2, 0 ]; } - token = state.push('tr_open', 'tr', 1); + token = state.push('tr_open', 'tr', 1); + token.map = [ nextLine, nextLine + 1 ]; + for (i = 0; i < columnCount; i++) { token = state.push('td_open', 'td', 1); - token.map = [ nextLine, nextLine + 1 ]; if (aligns[i]) { token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ]; } token = state.push('inline', '', 0); - token.map = [ nextLine, nextLine + 1 ]; token.content = columns[i] ? columns[i].trim() : ''; token.children = [];