Emphasis closer is found inside code spans and inline parser ranges

Ouverte
#41 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
68/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
typescript

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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).

Langage dominant
TypeScript
Étoiles
433
Forks
12
Merge moyen
29 min
PR mergées (30 j)
7

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de TanStack/markdown

Toutes les issues de TanStack/markdown

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.