Code span inside link text drops the backslash or ends the link early (\], \[, backtick)

オープン
#4,176 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

@hakarrr がすでに取り組んでいます。

2026年11月9日 から。

  • #1 @young1lin による — マージされずにクローズ
  • #83 @lockfile-maintenance による — マージ済み
  • #4180 @young1lin による — マージされずにクローズ
  • #4209 @hakarrr による — オープン

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript
領域
tooling

調査の方向性

Start by running the three inputs in the issue through new Marked().parse(input) and comparing them with the expected <a> and <code> output. The payload names no source files, so locate the inline rules that handle code spans and link brackets, and check which one wins when a code span sits inside link text. Done when all three cases match the CommonMark output, with backslashes kept literal inside <code> and the second link in case 3 parsed separately.

索引モデルが issue の本文から書いたものです。

説明

category: inline elements L2 - annoying

Marked version: 18.1.2

Describe the bug

A code span inside link text loses its literal backslash, or ends the link early, when its content contains a backslash, a square bracket or a backtick. In CommonMark, code span content is literal (no backslash escapes), and code spans bind more tightly than link brackets.

To Reproduce

Unmodified new Marked().parse(input); the trailing newline is omitted from the output.

1. Input:    [`\]`](https://x.test/)
   Expected: <p><a href="https://x.test/"><code>\]</code></a></p>
   Actual:   <p><a href="https://x.test/"><code>]</code></a></p>

2. Input:    [`\[`](https://x.test/)
   Expected: <p><a href="https://x.test/"><code>\[</code></a></p>
   Actual:   <p><a href="https://x.test/"><code>[</code></a></p>

3. Input:    [`` ` ``](https://x.test/)[\`](https://x.test/)
   Expected: <p><a href="https://x.test/"><code>`</code></a><a href="https://x.test/">`</a></p>
   Actual:   <p><a href="https://x.test/"><code>`</code>](https://x.test/)[`</a></p>

Expected behavior

Matches the CommonMark reference implementation: the code span's content stays literal inside link text, and the second link in case 3 is parsed separately.

Found with a property test over generated Markdown. The class is narrow: a code span inside link text whose content has a backtick, backslash or square bracket. Happy to test a fix.

主要言語
TypeScript
スター
37.3k
フォーク
3.9k
平均マージ
5日 6時間
マージ済み PR(30日)
62

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

markedjs/marked のほかの issue

markedjs/marked の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。