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