Commit Graph
2 Commits
Author SHA1 Message Date
EMEEEEMMMM 1e722fa84a fix: copy-paste restores original LaTeX source instead of Unicode glyphs
Desktop (Wails):
- MarkdownRenderer annotates .katex/.katex-display/.katex-html with
  data-latex-source attribute from rehype-katex MathML annotation
- messageSelectionCopy handler reads data-latex-source and replaces
  KaTeX rendered text with the original $...$ / ... LaTeX markup
- Auto-locks to the full formula when any part is selected
- Collects all display blocks in the range for multi-row formulas

CLI (TUI):
- mathNode retains both value (Unicode display) and source (raw LaTeX)
- mdRenderer gains rawMath mode and RenderRaw() method
- renderAssistantMarkdownRaw builds a parallel transcript with
  raw LaTeX preserving $...$ delimiters
- selectedText() uses rawWrappedLines when available to restore
  original LaTeX on clipboard copy

Fixes: Ctrl+C copy of LaTeX math expressions in both desktop and CLI
2026-07-28 16:43:21 +08:00
YHHandreasonix da84e11369 feat(cli): render LaTeX math as Unicode in chat output (#2757)
Model answers routinely contain $...$ and $$...$$ (also \(..\), \[..\])
math that previously printed as raw backslash commands. A goldmark inline
parser now converts it to a terminal-readable Unicode approximation —
Greek, operators/relations, super/subscripts, \frac, \sqrt, accents — so
the markdown pipeline renders it inline without breaking the streaming
flush boundary or width counting. A currency guard keeps "$5 and $10"
prose, and code spans/fences pass through untouched.

Co-authored-by: reasonix <[email protected]>
2026-06-02 07:13:10 -07:00