Skip to content
Source
Sign inSign up
TanStack/markdown

Asterisks surrounded by spaces are parsed as emphasis (`a * b * c` → `a <em> b </em> c`) #28

Send to my agent
Opengak10100(GitHub profile, opens in a new tab) opened this issue 0 comments

Version: @tanstack/markdown 1.0.0 (renderHtml and the React adapter)

Repro

import { renderHtml } from '@tanstack/markdown/html'

renderHtml('5 * 4 * 3 = 60')
// actual:   <p>5 <em> 4 </em> 3 = 60</p>
// expected: <p>5 * 4 * 3 = 60</p>

renderHtml('a * b * c')
// actual:   <p>a <em> b </em> c</p>
// expected: <p>a * b * c</p>

Expected

Under CommonMark's delimiter-run rules, a * followed by whitespace is not left-flanking, so it can't open emphasis. A * preceded by whitespace is not right-flanking, so it can't close emphasis. Both delimiters here have whitespace on both sides, so the text should render literally.

Other parsers agree:

Inputcommonmark.js 0.31.2markdown-it 15.0.2micromark 4.0.3@tanstack/markdown 1.0.0
5 * 4 * 3 = 605 * 4 * 3 = 605 * 4 * 3 = 605 * 4 * 3 = 605 <em> 4 </em> 3 = 60
a * b * ca * b * ca * b * ca * b * ca <em> b </em> c
*real italic*<em>real italic</em><em>real italic</em><em>real italic</em><em>real italic</em>

Why it matters

Arithmetic and multiplication in plain text (2 * 3, width * height) are common in user-written notes, and they silently turn into italics.

Escaped asterisks (5 \* 4 \* 3) render correctly. Only the flanking check on unescaped delimiters is affected.

Sign in to join this conversation.