Browse Source

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
pull/722/head
Alex Kocharin 4 years ago
parent
commit
9fe835bc12
  1. 3
      CHANGELOG.md
  2. 8
      lib/rules_block/table.js

3
CHANGELOG.md

@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added 3rd argument to `highlight(code, lang, attrs)`, #626. - Added 3rd argument to `highlight(code, lang, attrs)`, #626.
- Rewrite tables according to latest GFM spec, #697. - Rewrite tables according to latest GFM spec, #697.
### Fixed
- Fix mappings for table rows (amended fix made in 11.0.1), #705.
## [11.0.1] - 2020-09-14 ## [11.0.1] - 2020-09-14
### Fixed ### Fixed

8
lib/rules_block/table.js

@ -140,14 +140,12 @@ module.exports = function table(state, startLine, endLine, silent) {
for (i = 0; i < columns.length; i++) { for (i = 0; i < columns.length; i++) {
token = state.push('th_open', 'th', 1); token = state.push('th_open', 'th', 1);
token.map = [ startLine, startLine + 1 ];
if (aligns[i]) { if (aligns[i]) {
token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ]; token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
} }
token = state.push('inline', '', 0); token = state.push('inline', '', 0);
token.content = columns[i].trim(); token.content = columns[i].trim();
token.map = [ startLine, startLine + 1 ];
token.children = []; token.children = [];
token = state.push('th_close', 'th', -1); 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.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++) { for (i = 0; i < columnCount; i++) {
token = state.push('td_open', 'td', 1); token = state.push('td_open', 'td', 1);
token.map = [ nextLine, nextLine + 1 ];
if (aligns[i]) { if (aligns[i]) {
token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ]; token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
} }
token = state.push('inline', '', 0); token = state.push('inline', '', 0);
token.map = [ nextLine, nextLine + 1 ];
token.content = columns[i] ? columns[i].trim() : ''; token.content = columns[i] ? columns[i].trim() : '';
token.children = []; token.children = [];

Loading…
Cancel
Save