Emphasis closer is found inside code spans and inline parser ranges
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- backend-api-design
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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).
- Lingua principale
- TypeScript
- Stelle
- 433
- Fork
- 12
- Merge medio
- 29m
- PR unite (30g)
- 7
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/markdown
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 70/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
Tutte le issue di TanStack/markdown
Issue simili
-
Type/Improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
OpenNSW/nsw-srilanka#1259 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
oxc-project/tsrs#1010 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Fission-AI/OpenSpec#2260 ·
I maintainer di solito rispondono entro 1 giorno
-
Add: ESP 1 UKApertacheck:passed streams:add
Difficoltà 1/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
area:infra area:storage bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
THU-MAIC/OpenMAIC#2311 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno