Deep freeze name/tokens/lines/frontMatterLines properties of params object before passing to (custom) rules for shared access.

This commit is contained in:
David Anson 2021-12-23 04:34:25 +00:00 committed by GitHub
parent 5253669495
commit 5f0040679d
4 changed files with 98 additions and 16 deletions

View file

@ -206,6 +206,11 @@ function annotateTokens(tokens, lines) {
if (!token.map && trMap) {
token.map = [ ...trMap ];
}
// Adjust maps for math blocks
if (helpers.isMathBlock(token) && token.map[1]) {
// markdown-it-texmath plugin does not account for math_block_end
token.map[1]++;
}
// Update token metadata
if (token.map) {
token.line = lines[token.map[0]];
@ -481,10 +486,10 @@ function lintContent(
);
// Create parameters for rules
const params = {
name,
tokens,
lines,
frontMatterLines
"name": helpers.deepFreeze(name),
"tokens": helpers.deepFreeze(tokens),
"lines": helpers.deepFreeze(lines),
"frontMatterLines": helpers.deepFreeze(frontMatterLines)
};
cache.lineMetadata(helpers.getLineMetadata(params));
cache.flattenedLists(helpers.flattenLists(params.tokens));