Emphasis closer is found inside code spans and inline parser ranges
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- backend-api-design
Research direction
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.
Written by the indexing model from the issue text.
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).
- Dominant language
- TypeScript
- Stars
- 433
- Forks
- 12
- Avg merge
- 29m
- Merged PRs (30d)
- 7
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TanStack/markdown
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 3/5 Half a day Newbie friendliness 70/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
All issues in TanStack/markdown
Similar issues
-
Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
OpenNSW/nsw-srilanka#1259 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
oxc-project/tsrs#1010 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Fission-AI/OpenSpec#2260 ·
Maintainers usually reply within 1 day
-
Add: ESP 1 UKOpencheck:passed streams:add
Difficulty 1/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
area:infra area:storage bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
THU-MAIC/OpenMAIC#2311 · 1 comment ·
Maintainers usually reply within 1 day