Version: @tanstack/highlight 0.0.9
Prose inside JSX text nodes is tokenized as if it were code: English words that collide with keywords get keyword, digits get number, and Capitalized words get type.
Repro
import { createHighlighter } from '@tanstack/highlight/core'
import { tsx } from '@tanstack/highlight/languages/tsx'
const h = createHighlighter({ languages: [tsx] })
console.log(h.tokenize('<Trigger>How do I get started?</Trigger>', { lang: 'tsx' }).tokens)
console.log(h.tokenize('<Item>Option 1</Item>', { lang: 'tsx' }).tokens)
Actual:
["<", ["Trigger","tag"], ">", ["How","type"], " ", ["do","keyword"], " ", ["I","type"], " ", ["get","keyword"], " started?</", ["Trigger","tag"], ">"]
["<", ["Item","tag"], ">", ["Option","type"], " ", ["1","number"], "</", ["Item","tag"], ">"]
So a sentence like "How do I get started?" renders with do and get in keyword red and How/I in the type color, and "Option 1" gets a colored digit.
Expected: text between > and the next < is inert prose with no token classes (this is also how TextMate-grammar highlighters treat JSX text).
I realize the Capitalized-identifier→type heuristic is a deliberate trade-off elsewhere, but inside a JSX text node there's no ambiguity to trade against — filing since FAQ/accuracy docs suggest corpus-driven reports are welcome. Found while migrating dotui.org's docs from shiki, character-diffing both engines over ~733k chars of tsx; button/FAQ/label copy hits this constantly.
Version:
@tanstack/highlight0.0.9Prose inside JSX text nodes is tokenized as if it were code: English words that collide with keywords get
keyword, digits getnumber, and Capitalized words gettype.Repro
Actual:
So a sentence like "How do I get started?" renders with
doandgetin keyword red andHow/Iin the type color, and "Option 1" gets a colored digit.Expected: text between
>and the next<is inert prose with no token classes (this is also how TextMate-grammar highlighters treat JSX text).I realize the Capitalized-identifier→
typeheuristic is a deliberate trade-off elsewhere, but inside a JSX text node there's no ambiguity to trade against — filing since FAQ/accuracy docs suggest corpus-driven reports are welcome. Found while migrating dotui.org's docs from shiki, character-diffing both engines over ~733k chars of tsx; button/FAQ/label copy hits this constantly.