mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Deep freeze name/tokens/lines/frontMatterLines properties of params object before passing to (custom) rules for shared access.
This commit is contained in:
parent
5253669495
commit
5f0040679d
4 changed files with 98 additions and 16 deletions
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue