mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 05:50:13 +01:00
Handle missing token.map for th_open tokens (breaking) change in markdown-it v12.
This commit is contained in:
parent
77594dbf77
commit
85563c3e63
2 changed files with 26 additions and 10 deletions
|
|
@ -176,18 +176,27 @@ function removeFrontMatter(content, frontMatter) {
|
|||
* @returns {void}
|
||||
*/
|
||||
function annotateTokens(tokens, lines) {
|
||||
let tbodyMap = null;
|
||||
let tableMap = null;
|
||||
tokens.forEach(function forToken(token) {
|
||||
// Handle missing maps for table body
|
||||
if (token.type === "tbody_open") {
|
||||
tbodyMap = token.map.slice();
|
||||
} else if ((token.type === "tr_close") && tbodyMap) {
|
||||
tbodyMap[0]++;
|
||||
} else if (token.type === "tbody_close") {
|
||||
tbodyMap = null;
|
||||
// Handle missing maps for table head/body
|
||||
if (
|
||||
(token.type === "thead_open") ||
|
||||
(token.type === "tbody_open")
|
||||
) {
|
||||
tableMap = token.map.slice();
|
||||
} else if (
|
||||
(token.type === "tr_close") &&
|
||||
tableMap
|
||||
) {
|
||||
tableMap[0]++;
|
||||
} else if (
|
||||
(token.type === "thead_close") ||
|
||||
(token.type === "tbody_close")
|
||||
) {
|
||||
tableMap = null;
|
||||
}
|
||||
if (tbodyMap && !token.map) {
|
||||
token.map = tbodyMap.slice();
|
||||
if (tableMap && !token.map) {
|
||||
token.map = tableMap.slice();
|
||||
}
|
||||
// Update token metadata
|
||||
if (token.map) {
|
||||
|
|
|
|||
7
test/table-issue-with-markdown-it-12.md
Normal file
7
test/table-issue-with-markdown-it-12.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# table-issue-with-markdown-it-12
|
||||
|
||||
| `CLIEngine` | `ESLint` |
|
||||
| :------------------------------------------- | :--------------------------------- |
|
||||
| `executeOnFiles(patterns)` | `lintFiles(patterns)` |
|
||||
|
||||
<!-- markdownlint-disable-file MD013 -->
|
||||
Loading…
Add table
Add a link
Reference in a new issue