Skip to content

Commit

Permalink
Fix mappings for table rows
Browse files Browse the repository at this point in the history
 - `table`, `tbody`, `tr` now have mapping
 - `th`, `td`, `inline` in tables do not have it

close #705
  • Loading branch information
rlidwka committed Sep 25, 2020
1 parent be9e92b commit f95349e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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.
- Rewrite tables according to latest GFM spec, #697.

### Fixed
- Fix mappings for table rows, #705.


## [11.0.1] - 2020-09-14
### Fixed
Expand Down
8 changes: 3 additions & 5 deletions lib/rules_block/table.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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 = [];

Expand Down

0 comments on commit f95349e

Please sign in to comment.