mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update helpers.forEachInlineCodeSpan to remove backtick detection in link destinations for ~22% time reduction measured via profile-fixture.mjs on GitHub Codespaces.
This commit is contained in:
parent
e8cdb5619c
commit
d177ee2fc5
2 changed files with 2 additions and 32 deletions
|
@ -446,28 +446,12 @@ function forEachInlineCodeSpan(input, handler) {
|
||||||
let startColumn = -1;
|
let startColumn = -1;
|
||||||
let tickCount = 0;
|
let tickCount = 0;
|
||||||
let currentTicks = 0;
|
let currentTicks = 0;
|
||||||
let state = "normal";
|
|
||||||
// Deliberate <= so trailing 0 completes the last span (ex: "text `code`")
|
// Deliberate <= so trailing 0 completes the last span (ex: "text `code`")
|
||||||
// False-positive for js/index-out-of-bounds
|
// False-positive for js/index-out-of-bounds
|
||||||
for (; index <= input.length; index++) {
|
for (; index <= input.length; index++) {
|
||||||
const char = input[index];
|
const char = input[index];
|
||||||
// Ignore backticks in link destination
|
|
||||||
if ((char === "[") && (state === "normal")) {
|
|
||||||
state = "linkTextOpen";
|
|
||||||
}
|
|
||||||
else if ((char === "]") && (state === "linkTextOpen")) {
|
|
||||||
state = "linkTextClosed";
|
|
||||||
}
|
|
||||||
else if ((char === "(") && (state === "linkTextClosed")) {
|
|
||||||
state = "linkDestinationOpen";
|
|
||||||
}
|
|
||||||
else if (((char === "(") && (state === "linkDestinationOpen")) ||
|
|
||||||
((char === ")") && (state === "linkDestinationOpen")) ||
|
|
||||||
(state === "linkTextClosed")) {
|
|
||||||
state = "normal";
|
|
||||||
}
|
|
||||||
// Parse backtick open/close
|
// Parse backtick open/close
|
||||||
if ((char === "`") && (state !== "linkDestinationOpen")) {
|
if (char === "`") {
|
||||||
// Count backticks at start or end of code span
|
// Count backticks at start or end of code span
|
||||||
currentTicks++;
|
currentTicks++;
|
||||||
if ((startIndex === -1) || (startColumn === -1)) {
|
if ((startIndex === -1) || (startColumn === -1)) {
|
||||||
|
|
|
@ -446,26 +446,12 @@ function forEachInlineCodeSpan(input, handler) {
|
||||||
let startColumn = -1;
|
let startColumn = -1;
|
||||||
let tickCount = 0;
|
let tickCount = 0;
|
||||||
let currentTicks = 0;
|
let currentTicks = 0;
|
||||||
let state = "normal";
|
|
||||||
// Deliberate <= so trailing 0 completes the last span (ex: "text `code`")
|
// Deliberate <= so trailing 0 completes the last span (ex: "text `code`")
|
||||||
// False-positive for js/index-out-of-bounds
|
// False-positive for js/index-out-of-bounds
|
||||||
for (; index <= input.length; index++) {
|
for (; index <= input.length; index++) {
|
||||||
const char = input[index];
|
const char = input[index];
|
||||||
// Ignore backticks in link destination
|
|
||||||
if ((char === "[") && (state === "normal")) {
|
|
||||||
state = "linkTextOpen";
|
|
||||||
} else if ((char === "]") && (state === "linkTextOpen")) {
|
|
||||||
state = "linkTextClosed";
|
|
||||||
} else if ((char === "(") && (state === "linkTextClosed")) {
|
|
||||||
state = "linkDestinationOpen";
|
|
||||||
} else if (
|
|
||||||
((char === "(") && (state === "linkDestinationOpen")) ||
|
|
||||||
((char === ")") && (state === "linkDestinationOpen")) ||
|
|
||||||
(state === "linkTextClosed")) {
|
|
||||||
state = "normal";
|
|
||||||
}
|
|
||||||
// Parse backtick open/close
|
// Parse backtick open/close
|
||||||
if ((char === "`") && (state !== "linkDestinationOpen")) {
|
if (char === "`") {
|
||||||
// Count backticks at start or end of code span
|
// Count backticks at start or end of code span
|
||||||
currentTicks++;
|
currentTicks++;
|
||||||
if ((startIndex === -1) || (startColumn === -1)) {
|
if ((startIndex === -1) || (startColumn === -1)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue