mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10: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}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function annotateTokens(tokens, lines) {
|
function annotateTokens(tokens, lines) {
|
||||||
let tbodyMap = null;
|
let tableMap = null;
|
||||||
tokens.forEach(function forToken(token) {
|
tokens.forEach(function forToken(token) {
|
||||||
// Handle missing maps for table body
|
// Handle missing maps for table head/body
|
||||||
if (token.type === "tbody_open") {
|
if (
|
||||||
tbodyMap = token.map.slice();
|
(token.type === "thead_open") ||
|
||||||
} else if ((token.type === "tr_close") && tbodyMap) {
|
(token.type === "tbody_open")
|
||||||
tbodyMap[0]++;
|
) {
|
||||||
} else if (token.type === "tbody_close") {
|
tableMap = token.map.slice();
|
||||||
tbodyMap = null;
|
} 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) {
|
if (tableMap && !token.map) {
|
||||||
token.map = tbodyMap.slice();
|
token.map = tableMap.slice();
|
||||||
}
|
}
|
||||||
// Update token metadata
|
// Update token metadata
|
||||||
if (token.map) {
|
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