Skip to content

JSX: Allow apostrophes in element text (#2816) - #3214

Merged
birkenfeld merged 2 commits into
pygments:masterfrom
Sanjays2402:fix/jsx-apostrophe-text
Jul 14, 2026
Merged

JSX: Allow apostrophes in element text (#2816)#3214
birkenfeld merged 2 commits into
pygments:masterfrom
Sanjays2402:fix/jsx-apostrophe-text

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

JSX element text currently falls through to the inherited JavaScript rules, so an apostrophe in a contraction becomes an Error token and strict consumers such as Sphinx reject valid JSX. This adds a text fallback after normal JavaScript and TypeScript string handling, with a golden regression fixture.

Fixes #2816

Sanjays2402 and others added 2 commits July 13, 2026 08:05
JSX child text falls through to the inherited JavaScript rules, where an
apostrophe is not a valid standalone token and becomes an Error token.

Treat unmatched apostrophes as text after inherited string rules, preserving
normal JavaScript and TypeScript strings. Add golden regression coverage.

Fixes pygments#2816
@birkenfeld

Copy link
Copy Markdown
Member

Thank you!

@birkenfeld
birkenfeld merged commit 5b57bea into pygments:master Jul 14, 2026
17 checks passed
@stevepiercy

Copy link
Copy Markdown
Contributor

@Sanjays2402 thank you for this fix, too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WARNING: Lexing literal_block ... as "jsx" resulted in an error at token: "'". Retrying in relaxed mode.

3 participants