Emphasis closer is found inside code spans and inline parser ranges
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
- Domaine
- backend-api-design
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
inlineParserextension consumes, for example a link fromautolinksExtension() - 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 tohttps://faceit.com/players/_Santiago_*see https://example.com/*x*/y*: emphasis that contains a link tohttps://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
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de TanStack/markdown
-
Strong ending in nested emphasis (`**bold *italic***`) closes early and leaves a literal `*`Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
-
Difficulté 3/5 Une demi-journée Accessibilité débutants 70/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
Toutes les issues de TanStack/markdown
Issues similaires
-
Type/Improvement
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
OpenNSW/nsw-srilanka#1259 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
oxc-project/tsrs#1010 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Fission-AI/OpenSpec#2260 ·
Les mainteneurs répondent en général sous 1 jour
-
Add: ESP 1 UKOuvertecheck:passed streams:add
Difficulté 1/5 1-3 heures Accessibilité débutants 64/100
Les mainteneurs répondent en général sous 1 jour
-
area:infra area:storage bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
THU-MAIC/OpenMAIC#2311 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour