Dollar signs ($) parsed as LaTeX math inside backtick code spans, corrupting rendered text

Status Fixed / completed
Reported on v2.1.159
Maintainer reply ✓ Yes — amorriscode
Activity 5 comments · opened Jun 1, 2026 · closed Jun 2, 2026
💡 Likely answer: A maintainer (amorriscode, contributor) responded on this thread — see the highlighted reply below.

What's Wrong?

In the Claude Code desktop/GUI chat renderer, $ characters are treated as LaTeX/KaTeX math delimiters even inside inline code spans (backtick-delimited). Two $ on a line pair up and everything between them is typeset as math: spaces are collapsed, ** becomes ∗∗, and the $ delimiters are consumed and disappear.

This violates CommonMark: the contents of an inline code span are literal text, and no other inline construct (emphasis, links, autolinks, etc.) is recognized inside backticks. Math delimiters must not be either.

Real example

The assistant wrote (correctly, in markdown source):

...whether `${CLAUDE_SKILL_DIR}` expands in model-issued Bash calls...
Per the docs, `${CLAUDE_SKILL_DIR}` is specifically "the skill's subdirectory..."

The first $ opened a math span, the second $ closed it, and the entire region between them rendered as serif math-italic with whitespace collapsed ("expandsinmodel", "issuedBashcalls"). The second ${CLAUDE_SKILL_DIR} rendered as {CLAUDE_SKILL_DIR} — the $ had been eaten as the closing delimiter. (Screenshot below.)

What Should Happen

$ inside a backtick code span renders as a literal $, with all surrounding text and whitespace intact. Math detection must run after / with respect for code-span boundaries.

Steps to Reproduce

  1. In the GUI chat, have the assistant output a line containing two backtick code spans that each include a $, e.g. ${FOO} ... ${BAR}.
  2. Observe that the text between the two $ renders as KaTeX math instead of literal text.

Related

#33620 reported the general "$ triggers LaTeX math" corruption but was closed NOT_PLANNED by the stale-bot (and is now locked). This issue narrows it to the clear spec-violation: math rendering inside inline code spans. Shell-variable syntax (${VAR}, $PATH) makes this hit constantly in a coding tool.

Version / Platform

  • Claude Code 2.1.159, macOS 26.3.1, desktop GUI chat renderer
  • Model: Opus

_(Screenshot of the corrupted render to be attached.)_

View original on GitHub ↗

5 Comments

nevyn · 4 months ago

<img width="868" height="184" alt="Image" src="https://github.com/user-attachments/assets/39a62f2c-39ab-444d-9b95-535a6b29060e" />

github-actions[bot] · 4 months ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/33620

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

nevyn · 4 months ago

Bot: The original is closed even though the bug remains. Reopen it and I will thumbs it up.

amorriscode contributor · 4 months ago

Merged a fix for this, should have been deployed ~2 hours ago.

github-actions[bot] · 2 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.