TUI: option to keep TeX math verbatim in the final render, for terminals that typeset it
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
Summary
Please add a way to keep TeX math verbatim in the TUI's final render — an option, or a rule that leaves $…$ / $$…$$ / \(…\) / \[…\] untouched when the terminal says it can typeset them — so that a terminal which renders LaTeX in command output receives the bytes the model wrote.
Background
Until #45501 and #45612 (0.155 alphas) the TUI's final redraw ran assistant text through CommonMark with no math protection. On 0.153.4 the effect on a display block is:
\\→\(every matrix /aligned/casesrow separator loses a backslash),\,→,,\!→!,\[/\]→[/],- a line holding only
=— anA x = bwritten across three lines of matrices — is taken as a setext underline: the paragraph above becomes an H1, shown as# $$ …, and the=is deleted.
Reproduction (0.153.4, Windows 11): ask for exactly
矩阵乘法
$$
\begin{pmatrix} a & b \\ c & d \end{pmatrix}
\begin{pmatrix} x \\ y \end{pmatrix}
=
\begin{pmatrix} ax + by \\ cx + dy \end{pmatrix}
$$
Streamed text is intact; the final redraw is # $$, rows ending in a single \, and no = line.
#45501 / #45612 mask math before the CommonMark pass, which fixes the corruption — thank you. But they then replace supported expressions with Unicode (α² + β₁₀, stacked fractions), and only unsupported ones fall back to source. For a terminal that typesets LaTeX itself (I maintain one, Folio, which typesets $…$ and $$…$$ where a program prints them), the Unicode form is a step down: the delimiters and the TeX are gone, so nothing can be typeset, and what is copied is no longer TeX.
Request
One of:
- A config key (e.g.
tui.math = "unicode" | "source") that keeps the masked spans verbatim instead of converting them; - or honouring an environment hint (a
TERM_PROGRAMallow-list, or a capability the terminal advertises) to picksourceautomatically.
The masking already exists after #45501, so source is the conversion step switched off — the delimiters and bytes are restored exactly as written, the way unsupported expressions already are.
Environment
- codex-cli 0.153.4, Windows 11, model gpt-6-astra
- Terminal: Folio 0.4.2 (typesets LaTeX in command output)
Contributor 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.
Research direction
Start by tracing the TUI math masking and conversion introduced by #45501 and #45612. Review the existing configuration or capability-detection entry points before choosing between an explicit source mode and terminal-based selection. Done means supported math can preserve its original delimiters and TeX bytes for capable terminals without regressing the current Unicode rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- latex, rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100