Problem
Model-generated scientific notation can contain a math-mode command inside a TeX text block, for example:
KaTeX rejects \mu in text mode. Scient then displays a code-styled fallback surrounded by manufactured $$ delimiters. The same fallback is used while loading and for render-boundary failures, so the visible result does not explain whether the source is unsupported, still loading, or failed for another reason.
Verified diagnosis
- Direct KaTeX rendering with Scient's options rejects
1.8\text{ \mu g/dL} with Undefined control sequence: \mu.
- The equivalent
1.8\,\mu\mathrm{g/dL} renders successfully.
- The stored message source contained the unsupported form; this was not caused by RTL layout or by the Markdown recognizer.
renderScientTexToHtml returns null on the KaTeX error, and ScientMathLiteral supplies the generic fallback.
Relevant code:
apps/web/src/scient/math/katexRuntime.ts
apps/web/src/scient/math/ScientMath.tsx
Desired behavior
Unsupported TeX should remain readable and copyable, preserve its actual source and delimiter form, and be distinguishable from a temporary loading state. Scient's supported-format guidance should show valid scientific-unit notation.
Targeted scope
- Preserve the original inline/display delimiter form in the fallback rather than always manufacturing
$$.
- Distinguish unsupported syntax from loading where that can be done without exposing internal errors in ordinary chat UI.
- Add supported examples for scientific units such as
1.8\,\mu\mathrm{g/dL}.
- Test inline and display math, streaming/loading, render errors, editing, and copying.
Non-goals
- Do not regex-rewrite arbitrary TeX.
- Do not silently move commands into or out of
\text{...}.
- Do not treat this malformed source as an RTL rendering defect.
Evidence limits
The renderer failure is deterministic in automated reproduction. Native visual behavior still needs manual review before closure.
Problem
Model-generated scientific notation can contain a math-mode command inside a TeX text block, for example:
$$1.8\text{ \mu g/dL}$$KaTeX rejects
\muin text mode. Scient then displays a code-styled fallback surrounded by manufactured$$delimiters. The same fallback is used while loading and for render-boundary failures, so the visible result does not explain whether the source is unsupported, still loading, or failed for another reason.Verified diagnosis
1.8\text{ \mu g/dL}withUndefined control sequence: \mu.1.8\,\mu\mathrm{g/dL}renders successfully.renderScientTexToHtmlreturnsnullon the KaTeX error, andScientMathLiteralsupplies the generic fallback.Relevant code:
apps/web/src/scient/math/katexRuntime.tsapps/web/src/scient/math/ScientMath.tsxDesired behavior
Unsupported TeX should remain readable and copyable, preserve its actual source and delimiter form, and be distinguishable from a temporary loading state. Scient's supported-format guidance should show valid scientific-unit notation.
Targeted scope
$$.1.8\,\mu\mathrm{g/dL}.Non-goals
\text{...}.Evidence limits
The renderer failure is deterministic in automated reproduction. Native visual behavior still needs manual review before closure.