Repository navigation
fix: keep literal codespan content inside link text - #4189
Open
dyk1454683243-sudo wants to merge 1 commit into
Open
dyk1454683243-sudo wants to merge 1 commit into
dyk1454683243-sudo wants to merge 1 commit into
Conversation
|
@cursoragent is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
Code spans bind tighter than link brackets, so a backslash inside a code span stays literal and a code span cannot borrow a closer from a later backtick run of a different length. Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
cursor
Bot
force-pushed
the
fix/4176-codespan-in-link-text
branch
from
November 3, 2026 23:52
7e89e09 to
0b6fe19
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4176
Marked version: 18.1.2
Markdown flavor: CommonMark
Description
Code spans bind tighter than link brackets, and their contents are literal. Two mistakes in link-label handling broke that:
outputLinkrancap[1].replace(/\\([\[\]])/g, '$1')over the whole label before inline lexing, so a backslash inside a code span was removed. Labels with no backtick still use that unescape. A label that also contains a backtick copies code spans through (same delimiter shape as inline code) and only unescapes brackets outside them.The code alternative in the inline label pattern (
`+(?!`)[^`]*?`+(?!`)) does not require the opening and closing backtick runs to be the same length, so a code span can borrow a closer from a later link. A backreference in that pattern would renumber the publichrefandtitlegroups, so the link regex is unchanged. When a non-pedantic match's label contains a backtick,Tokenizer.linkmeasures the label with the same rules as code spans and, if the real]is earlier, rebuilds the match from there. A]that does not start an inline destination deactivates that opener, and the end is never moved past the original match.Escaped brackets outside code spans are unchanged, including
\\[/\\].Contributor
New exact-output specs in
test/specs/new/:link_text_codespan_backslash—[`\]`](url)keeps the backslashlink_text_codespan_bracket—[`\[`](url)keeps the backslashlink_text_codespan_backtick—[``](url)[\](url) `` is two linkslink_text_escaped_bracket— brackets escaped outside a code span still unescape, including a double backslash and an image altlink_text_codespan_failed_closer— a]that does not close the link is not traded for a later destinationCommitter