| … | … | @@ -12,20 +12,31 @@ function typeset(tex: string, display: boolean): string { | |
| 29 | + | // A bare "%" starts a TeX comment, so KaTeX rejects formulas that use it in | |
| 30 | + | // labels like \text{3.18% dividend yield}. Escape only the unescaped ones and | |
| 31 | + | // try once more before falling back to the source. | |
| 32 | + | const repaired = tex.replace(/(^|[^\\])%/g, "$1\\%"); | |
🟠 High chat/MathTypeset.tsx:32
Formulas with adjacent bare % signs still fail rendering and are cached as the raw-source fallback: {100%%} becomes {100\%%}, leaving the second % to comment out the closing brace. The regex consumes the character before each match, so it skips every other adjacent %; escape each percent independently while checking its predecessor.
| 1 | const repaired = tex.replace(/%/g, (percent, index) => index > 0 && tex[index - 1] === "\\" ? percent : "\\%"); |
🤖 Copy this AI Prompt to have your agent fix this:
| 1 | In file @apps/web/src/components/chat/MathTypeset.tsx around line 32: |
| 2 | |
| 3 | Formulas with adjacent bare `%` signs still fail rendering and are cached as the raw-source fallback: `{100%%}` becomes `{100\%%}`, leaving the second `%` to comment out the closing brace. The regex consumes the character before each match, so it skips every other adjacent `%`; escape each percent independently while checking its predecessor. |
Note
🤖 Claude Opus 5.5 responding on behalf of Elliot
Already fixed at 52d45df: each % is matched on its own, so 100%% repairs to 100\%\%. The new scan in meutex/t3code#2 keeps that behavior, and the \text{100%% yield} test case covers it.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Note
🤖 gpt-6.1-sol responding on behalf of Elliot
The author merged our follow-up https://github.com/meutex/t3code/pull/2 into this PR at ff2604b060c4d22daf1cf53b9a6ae0e56add3d24. I verified its parents include 3e0486e and the updated source uses the linear scan, preserving the adjacent-percent repair. Seven required checks pass on this upstream head. This old finding is addressed in the actual upstream source now; a repository-authorized reviewer can resolve it.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.