mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Update all references to "params.tokens" to "params.parsers.markdownit.tokens" for clarity.
This commit is contained in:
parent
5302ee45de
commit
4b27bac79b
15 changed files with 45 additions and 37 deletions
|
@ -298,7 +298,7 @@ module.exports.unorderedListStyleFor = function unorderedListStyleFor(token) {
|
|||
* @returns {void}
|
||||
*/
|
||||
function filterTokens(params, type, handler) {
|
||||
var _iterator = _createForOfIteratorHelper(params.tokens),
|
||||
var _iterator = _createForOfIteratorHelper(params.parsers.markdownit.tokens),
|
||||
_step;
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
|
@ -358,7 +358,7 @@ module.exports.getLineMetadata = function getLineMetadata(params) {
|
|||
filterTokens(params, "hr", function (token) {
|
||||
lineMetadata[token.map[0]][6] = true;
|
||||
});
|
||||
var _iterator2 = _createForOfIteratorHelper(params.tokens.filter(isMathBlock)),
|
||||
var _iterator2 = _createForOfIteratorHelper(params.parsers.markdownit.tokens.filter(isMathBlock)),
|
||||
_step2;
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
|
@ -489,7 +489,7 @@ module.exports.forEachInlineChild = forEachInlineChild;
|
|||
// Calls the provided function for each heading's content
|
||||
module.exports.forEachHeading = function forEachHeading(params, handler) {
|
||||
var heading = null;
|
||||
var _iterator6 = _createForOfIteratorHelper(params.tokens),
|
||||
var _iterator6 = _createForOfIteratorHelper(params.parsers.markdownit.tokens),
|
||||
_step6;
|
||||
try {
|
||||
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
||||
|
@ -2463,7 +2463,7 @@ function lintContent(ruleList, name, content, md, config, configParsers, frontMa
|
|||
};
|
||||
var lineMetadata = helpers.getLineMetadata(paramsBase);
|
||||
var codeBlockAndSpanRanges = helpers.codeBlockAndSpanRanges(paramsBase, lineMetadata);
|
||||
var flattenedLists = helpers.flattenLists(paramsBase.tokens);
|
||||
var flattenedLists = helpers.flattenLists(paramsBase.parsers.markdownit.tokens);
|
||||
var htmlElementRanges = helpers.htmlElementRanges(paramsBase, lineMetadata);
|
||||
var referenceLinkImageData = helpers.getReferenceLinkImageData(paramsBase);
|
||||
cache.set({
|
||||
|
@ -3292,7 +3292,7 @@ module.exports = {
|
|||
"function": function MD002(params, onError) {
|
||||
var level = Number(params.config.level || 1);
|
||||
var tag = "h" + level;
|
||||
params.tokens.every(function forToken(token) {
|
||||
params.parsers.markdownit.tokens.every(function forToken(token) {
|
||||
if (token.type === "heading_open") {
|
||||
addErrorDetailIf(onError, token.lineNumber, tag, token.tag);
|
||||
return false;
|
||||
|
@ -4573,7 +4573,7 @@ module.exports = {
|
|||
"function": function MD027(params, onError) {
|
||||
var blockquoteNesting = 0;
|
||||
var listItemNesting = 0;
|
||||
var _iterator = _createForOfIteratorHelper(params.tokens),
|
||||
var _iterator = _createForOfIteratorHelper(params.parsers.markdownit.tokens),
|
||||
_step;
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
|
@ -4642,7 +4642,7 @@ module.exports = {
|
|||
"function": function MD028(params, onError) {
|
||||
var prevToken = {};
|
||||
var prevLineNumber = null;
|
||||
var _iterator = _createForOfIteratorHelper(params.tokens),
|
||||
var _iterator = _createForOfIteratorHelper(params.parsers.markdownit.tokens),
|
||||
_step;
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
|
@ -5214,7 +5214,7 @@ module.exports = {
|
|||
return base;
|
||||
}
|
||||
var state = base;
|
||||
var _iterator = _createForOfIteratorHelper(params.tokens),
|
||||
var _iterator = _createForOfIteratorHelper(params.parsers.markdownit.tokens),
|
||||
_step;
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
|
@ -5608,7 +5608,7 @@ module.exports = {
|
|||
var foundFrontMatterTitle = frontMatterHasTitle(params.frontMatterLines, params.config.front_matter_title);
|
||||
if (!foundFrontMatterTitle) {
|
||||
var htmlHeadingRe = new RegExp("^<h".concat(level, "[ />]"), "i");
|
||||
params.tokens.every(function (token) {
|
||||
params.parsers.markdownit.tokens.every(function (token) {
|
||||
var isError = false;
|
||||
if (token.type === "html_block") {
|
||||
if (token.content.startsWith("<!--")) {
|
||||
|
@ -5955,7 +5955,7 @@ module.exports = {
|
|||
"tags": ["code"],
|
||||
"function": function MD046(params, onError) {
|
||||
var expectedStyle = String(params.config.style || "consistent");
|
||||
var codeBlocksAndFences = params.tokens.filter(function (token) {
|
||||
var codeBlocksAndFences = params.parsers.markdownit.tokens.filter(function (token) {
|
||||
return token.type === "code_block" || token.type === "fence";
|
||||
});
|
||||
var _iterator = _createForOfIteratorHelper(codeBlocksAndFences),
|
||||
|
@ -6036,7 +6036,7 @@ module.exports = {
|
|||
"function": function MD048(params, onError) {
|
||||
var style = String(params.config.style || "consistent");
|
||||
var expectedStyle = style;
|
||||
var fenceTokens = params.tokens.filter(function (token) {
|
||||
var fenceTokens = params.parsers.markdownit.tokens.filter(function (token) {
|
||||
return token.type === "fence";
|
||||
});
|
||||
var _iterator = _createForOfIteratorHelper(fenceTokens),
|
||||
|
|
|
@ -34,7 +34,7 @@ module.exports = {
|
|||
"information": new URL("https://example.com/rules/any-blockquote"),
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
params.parsers.markdownit.tokens.filter(function filterToken(token) {
|
||||
return token.type === "blockquote_open";
|
||||
}).forEach(function forToken(blockquote) {
|
||||
var lines = blockquote.map[1] - blockquote.map[0];
|
||||
|
|
|
@ -273,7 +273,7 @@ module.exports.unorderedListStyleFor = function unorderedListStyleFor(token) {
|
|||
* @returns {void}
|
||||
*/
|
||||
function filterTokens(params, type, handler) {
|
||||
for (const token of params.tokens) {
|
||||
for (const token of params.parsers.markdownit.tokens) {
|
||||
if (token.type === type) {
|
||||
handler(token);
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ module.exports.getLineMetadata = function getLineMetadata(params) {
|
|||
filterTokens(params, "hr", (token) => {
|
||||
lineMetadata[token.map[0]][6] = true;
|
||||
});
|
||||
for (const token of params.tokens.filter(isMathBlock)) {
|
||||
for (const token of params.parsers.markdownit.tokens.filter(isMathBlock)) {
|
||||
for (let i = token.map[0]; i < token.map[1]; i++) {
|
||||
lineMetadata[i][7] = true;
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ module.exports.forEachInlineChild = forEachInlineChild;
|
|||
// Calls the provided function for each heading's content
|
||||
module.exports.forEachHeading = function forEachHeading(params, handler) {
|
||||
let heading = null;
|
||||
for (const token of params.tokens) {
|
||||
for (const token of params.parsers.markdownit.tokens) {
|
||||
if (token.type === "heading_open") {
|
||||
heading = token;
|
||||
} else if (token.type === "heading_close") {
|
||||
|
|
|
@ -579,7 +579,7 @@ function lintContent(
|
|||
const codeBlockAndSpanRanges =
|
||||
helpers.codeBlockAndSpanRanges(paramsBase, lineMetadata);
|
||||
const flattenedLists =
|
||||
helpers.flattenLists(paramsBase.tokens);
|
||||
helpers.flattenLists(paramsBase.parsers.markdownit.tokens);
|
||||
const htmlElementRanges =
|
||||
helpers.htmlElementRanges(paramsBase, lineMetadata);
|
||||
const referenceLinkImageData =
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = {
|
|||
"function": function MD002(params, onError) {
|
||||
const level = Number(params.config.level || 1);
|
||||
const tag = "h" + level;
|
||||
params.tokens.every(function forToken(token) {
|
||||
params.parsers.markdownit.tokens.every(function forToken(token) {
|
||||
if (token.type === "heading_open") {
|
||||
addErrorDetailIf(onError, token.lineNumber, tag, token.tag);
|
||||
return false;
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = {
|
|||
"function": function MD027(params, onError) {
|
||||
let blockquoteNesting = 0;
|
||||
let listItemNesting = 0;
|
||||
for (const token of params.tokens) {
|
||||
for (const token of params.parsers.markdownit.tokens) {
|
||||
const { content, lineNumber, type } = token;
|
||||
if (type === "blockquote_open") {
|
||||
blockquoteNesting++;
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = {
|
|||
"function": function MD028(params, onError) {
|
||||
let prevToken = {};
|
||||
let prevLineNumber = null;
|
||||
for (const token of params.tokens) {
|
||||
for (const token of params.parsers.markdownit.tokens) {
|
||||
if ((token.type === "blockquote_open") &&
|
||||
(prevToken.type === "blockquote_close")) {
|
||||
for (
|
||||
|
|
|
@ -49,7 +49,7 @@ module.exports = {
|
|||
return base;
|
||||
}
|
||||
let state = base;
|
||||
for (const token of params.tokens) {
|
||||
for (const token of params.parsers.markdownit.tokens) {
|
||||
state = state(token);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = {
|
|||
);
|
||||
if (!foundFrontMatterTitle) {
|
||||
const htmlHeadingRe = new RegExp(`^<h${level}[ />]`, "i");
|
||||
params.tokens.every((token) => {
|
||||
params.parsers.markdownit.tokens.every((token) => {
|
||||
let isError = false;
|
||||
if (token.type === "html_block") {
|
||||
if (token.content.startsWith("<!--")) {
|
||||
|
|
|
@ -15,7 +15,7 @@ module.exports = {
|
|||
"tags": [ "code" ],
|
||||
"function": function MD046(params, onError) {
|
||||
let expectedStyle = String(params.config.style || "consistent");
|
||||
const codeBlocksAndFences = params.tokens.filter(
|
||||
const codeBlocksAndFences = params.parsers.markdownit.tokens.filter(
|
||||
(token) => (token.type === "code_block") || (token.type === "fence")
|
||||
);
|
||||
for (const token of codeBlocksAndFences) {
|
||||
|
|
|
@ -11,7 +11,9 @@ module.exports = {
|
|||
"function": function MD048(params, onError) {
|
||||
const style = String(params.config.style || "consistent");
|
||||
let expectedStyle = style;
|
||||
const fenceTokens = params.tokens.filter((token) => token.type === "fence");
|
||||
const fenceTokens = params.parsers.markdownit.tokens.filter(
|
||||
(token) => token.type === "fence"
|
||||
);
|
||||
for (const fenceToken of fenceTokens) {
|
||||
const { lineNumber, markup } = fenceToken;
|
||||
if (expectedStyle === "consistent") {
|
||||
|
|
|
@ -1199,12 +1199,16 @@ test("htmlElementRanges", (t) => {
|
|||
"Text `<br/>` text",
|
||||
"text <br/> text"
|
||||
],
|
||||
"tokens": [
|
||||
{
|
||||
"type": "code_block",
|
||||
"map": [ 10, 12 ]
|
||||
"parsers": {
|
||||
"markdownit": {
|
||||
"tokens": [
|
||||
{
|
||||
"type": "code_block",
|
||||
"map": [ 10, 12 ]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
const expected = [
|
||||
[ 3, 5, 12 ],
|
||||
|
|
|
@ -1193,7 +1193,9 @@ test("token-map-spans", (t) => {
|
|||
"function": function tokenMapSpans(params) {
|
||||
const tokenLines = [];
|
||||
let lastLineNumber = -1;
|
||||
const inlines = params.tokens.filter((c) => c.type === "inline");
|
||||
const inlines = params.parsers.markdownit.tokens.filter(
|
||||
(c) => c.type === "inline"
|
||||
);
|
||||
for (const token of inlines) {
|
||||
t.truthy(token.map);
|
||||
for (let i = token.map[0]; i < token.map[1]; i++) {
|
||||
|
|
|
@ -10,13 +10,13 @@ module.exports = {
|
|||
"/blob/main/test/rules/letters-E-X.js"
|
||||
),
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
for (const inline of params.tokens.filter(function filterToken(token) {
|
||||
return token.type === "inline";
|
||||
})) {
|
||||
for (const text of inline.children.filter(function filterChild(child) {
|
||||
return child.type === "text";
|
||||
})) {
|
||||
"function": (params, onError) => {
|
||||
for (const inline of params.parsers.markdownit.tokens.filter(
|
||||
(token) => token.type === "inline"
|
||||
)) {
|
||||
for (const text of inline.children.filter(
|
||||
(child) => child.type === "text"
|
||||
)) {
|
||||
const index = text.content.toLowerCase().indexOf("ex");
|
||||
if (index !== -1) {
|
||||
onError({
|
||||
|
|
|
@ -7,7 +7,7 @@ module.exports = {
|
|||
"description": "Sample rule",
|
||||
"tags": [ "sample" ],
|
||||
"function": function rule(params, onError) {
|
||||
for (const token of params.tokens) {
|
||||
for (const token of params.parsers.markdownit.tokens) {
|
||||
if (token.type === "hr") {
|
||||
onError({
|
||||
"lineNumber": token.lineNumber,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue