mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01:00
Refactor to remove codeBlockAndSpanRanges helper.
This commit is contained in:
parent
c5f4a93cc7
commit
7efc2605b1
7 changed files with 96 additions and 128 deletions
20
lib/md010.js
20
lib/md010.js
|
|
@ -3,7 +3,7 @@
|
|||
"use strict";
|
||||
|
||||
const { addError, withinAnyRange } = require("../helpers");
|
||||
const { filterByTypes, getDescendantsByType } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypes, getDescendantsByType, getExclusionsForToken } = require("../helpers/micromark.cjs");
|
||||
|
||||
const tabRe = /\t+/g;
|
||||
|
||||
|
|
@ -47,20 +47,12 @@ module.exports = {
|
|||
return true;
|
||||
});
|
||||
for (const codeToken of codeTokens) {
|
||||
const codeFenced = (codeToken.type === "codeFenced");
|
||||
const startLine = codeToken.startLine + (codeFenced ? 1 : 0);
|
||||
const endLine = codeToken.endLine - (codeFenced ? 1 : 0);
|
||||
for (let lineNumber = startLine; lineNumber <= endLine; lineNumber++) {
|
||||
const startColumn =
|
||||
(lineNumber === codeToken.startLine) ? codeToken.startColumn : 1;
|
||||
const endColumn =
|
||||
(lineNumber === codeToken.endLine) ? codeToken.endColumn : params.lines[lineNumber - 1].length;
|
||||
exclusions.push([
|
||||
lineNumber,
|
||||
startColumn,
|
||||
endColumn - startColumn + 1
|
||||
]);
|
||||
const exclusionsForToken = getExclusionsForToken(params.lines, codeToken);
|
||||
if (codeToken.type === "codeFenced") {
|
||||
exclusionsForToken.pop();
|
||||
exclusionsForToken.shift();
|
||||
}
|
||||
exclusions.push(...exclusionsForToken);
|
||||
}
|
||||
for (let lineIndex = 0; lineIndex < params.lines.length; lineIndex++) {
|
||||
const line = params.lines[lineIndex];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue