Cache results of inlineCodeSpanRanges for use by MD011/MD044.

This commit is contained in:
David Anson 2021-06-17 22:01:27 -07:00
parent 706f48bd25
commit 7d40926367
6 changed files with 56 additions and 39 deletions

View file

@ -2,9 +2,8 @@
"use strict";
const { addError, forEachLine, inlineCodeSpanRanges, overlapsAnyRange } =
require("../helpers");
const { lineMetadata } = require("./cache");
const { addError, forEachLine, overlapsAnyRange } = require("../helpers");
const { inlineCodeSpanRanges, lineMetadata } = require("./cache");
const reversedLinkRe =
/(?<![\\\]])\(([^)]+)(?<!\\)\)\[([^\]^][^\]]*)(?<!\\)](?!\()/g;
@ -14,7 +13,7 @@ module.exports = {
"description": "Reversed link syntax",
"tags": [ "links" ],
"function": function MD011(params, onError) {
const exclusions = inlineCodeSpanRanges(params.lines);
const exclusions = inlineCodeSpanRanges();
forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence) => {
if (!inCode && !onFence) {
let match = null;