mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD038/no-space-in-code to ignore backticks in link destinations (fixes #206).
This commit is contained in:
parent
cd7a65cedd
commit
c3e8eab87b
3 changed files with 46 additions and 2 deletions
|
@ -259,10 +259,25 @@ module.exports.forEachInlineCodeSpan =
|
|||
let startColumn = -1;
|
||||
let tickCount = 0;
|
||||
let currentTicks = 0;
|
||||
let state = "normal";
|
||||
// Deliberate <= so trailing 0 completes the last span (ex: "text `code`")
|
||||
for (; index <= input.length; index++) {
|
||||
const char = input[index];
|
||||
if (char === "`") {
|
||||
// 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
|
||||
if ((char === "`") && (state !== "linkDestinationOpen")) {
|
||||
// Count backticks at start or end of code span
|
||||
currentTicks++;
|
||||
if ((startIndex === -1) || (startColumn === -1)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue