mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Add tokenLists and use in filterTokens for ~10% time reduction.
This commit is contained in:
parent
096f4d7afd
commit
3e208b7bc5
2 changed files with 26 additions and 22 deletions
|
|
@ -58,6 +58,7 @@ function lintContent(content, config) {
|
|||
// Parse content into tokens and lines
|
||||
var tokens = md.parse(content, {});
|
||||
var lines = content.split(shared.newLineRe);
|
||||
var tokenLists = {};
|
||||
// Annotate tokens with line/lineNumber
|
||||
tokens.forEach(function forToken(token) {
|
||||
if (token.map) {
|
||||
|
|
@ -76,10 +77,15 @@ function lintContent(content, config) {
|
|||
}
|
||||
});
|
||||
}
|
||||
if (!tokenLists[token.type]) {
|
||||
tokenLists[token.type] = [];
|
||||
}
|
||||
tokenLists[token.type].push(token);
|
||||
});
|
||||
// Create parameters for rules
|
||||
var params = {
|
||||
"tokens": tokens,
|
||||
"tokenLists": tokenLists,
|
||||
"lines": lines
|
||||
};
|
||||
// Merge rules/tags and sanitize config
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue