mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-21 16:30:12 +01:00
Tokens inside tables that lack a map should get it from the surrounding table row (which is more scoped than the table body) (fixes #463).
This commit is contained in:
parent
1e82f76596
commit
11806dc5cb
6 changed files with 106 additions and 34 deletions
|
|
@ -181,27 +181,16 @@ function removeFrontMatter(content, frontMatter) {
|
|||
* @returns {void}
|
||||
*/
|
||||
function annotateTokens(tokens, lines) {
|
||||
let tableMap = null;
|
||||
let trMap = null;
|
||||
tokens.forEach(function forToken(token) {
|
||||
// Handle missing maps for table head/body
|
||||
if (
|
||||
(token.type === "thead_open") ||
|
||||
(token.type === "tbody_open")
|
||||
) {
|
||||
tableMap = [ ...token.map ];
|
||||
} else if (
|
||||
(token.type === "tr_close") &&
|
||||
tableMap
|
||||
) {
|
||||
tableMap[0]++;
|
||||
} else if (
|
||||
(token.type === "thead_close") ||
|
||||
(token.type === "tbody_close")
|
||||
) {
|
||||
tableMap = null;
|
||||
// Provide missing maps for table content
|
||||
if (token.type === "tr_open") {
|
||||
trMap = token.map;
|
||||
} else if (token.type === "tr_close") {
|
||||
trMap = null;
|
||||
}
|
||||
if (tableMap && !token.map) {
|
||||
token.map = [ ...tableMap ];
|
||||
if (!token.map && trMap) {
|
||||
token.map = [ ...trMap ];
|
||||
}
|
||||
// Update token metadata
|
||||
if (token.map) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue