Emphasis closer is found inside code spans and inline parser ranges

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

まだ誰も着手していません。

評価

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

調査の方向性

Start in src/inline.ts, reading parseInline and findDelimiter to understand how emphasis closers are found and how inline parsers and code spans are handled. Reproduce the three cases from the issue, then verify that links and code spans inside emphasis are parsed intact and run the relevant existing inline parser tests.

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

説明

Problem

When parseInline reads an emphasis opener (*, _ or ~), findDelimiter in src/inline.ts scans the raw text for the closer. The scan does not skip text that binds more tightly than emphasis, so it can find a closer inside:

  • a range that an inlineParser extension consumes, for example a link from autolinksExtension()
  • a code span

CommonMark gives code spans and autolinks a higher precedence than emphasis (spec 6.1). Without an opener before them, the same links parse correctly, because the inline parser runs first.

Reproduction

@tanstack/markdown 1.2.0:

import { parseInline } from '@tanstack/markdown'
import { autolinksExtension } from '@tanstack/markdown/extensions/autolinks'

const extensions = [autolinksExtension()]

parseInline('_see https://faceit.com/players/_Santiago_ now_', { extensions })
// emphasis: "see " + link https://faceit.com/players/_Santiago (wrong URL)
// text: " now_"

parseInline('*see https://example.com/*x*/y*', { extensions })
// emphasis: "see " + link https://example.com/
// text: "x", emphasis: "/y"

parseInline('*a `*` b*')
// emphasis: "a `", text: "` b*" (no code span)

Expected

  • _see https://faceit.com/players/_Santiago_ now_: emphasis that contains a link to https://faceit.com/players/_Santiago_
  • *see https://example.com/*x*/y*: emphasis that contains a link to https://example.com/*x*/y
  • *a `*` b*: emphasis that contains a code span with *

Possible fix

In findDelimiter, skip code spans as the main loop does. At a character that is in an inline parser's markers, call the parser and skip result.length characters when it matches. This makes the parser run twice for the same range, so the docs would need to say that parse must not have side effects.


Written by an agent (Claude Code, claude-opus-5-5).

主要言語
TypeScript
スター
433
フォーク
12
平均マージ
29分
マージ済み PR(30日)
7

環境構築

はじめの一歩

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

TanStack/markdown のほかの issue

TanStack/markdown の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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