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:
David Anson 2021-11-26 04:26:15 +00:00 committed by GitHub
parent 1e82f76596
commit 11806dc5cb
6 changed files with 106 additions and 34 deletions

View file

@ -1037,23 +1037,17 @@ function removeFrontMatter(content, frontMatter) {
* @returns {void}
*/
function annotateTokens(tokens, lines) {
var tableMap = null;
var trMap = null;
tokens.forEach(function forToken(token) {
// Handle missing maps for table head/body
if ((token.type === "thead_open") ||
(token.type === "tbody_open")) {
tableMap = __spreadArray([], token.map);
// Provide missing maps for table content
if (token.type === "tr_open") {
trMap = token.map;
}
else if ((token.type === "tr_close") &&
tableMap) {
tableMap[0]++;
else if (token.type === "tr_close") {
trMap = null;
}
else if ((token.type === "thead_close") ||
(token.type === "tbody_close")) {
tableMap = null;
}
if (tableMap && !token.map) {
token.map = __spreadArray([], tableMap);
if (!token.map && trMap) {
token.map = __spreadArray([], trMap);
}
// Update token metadata
if (token.map) {