Skip to content

desktop: render LaTeX math in messages #51432

Closed as not planned
Closed as not planned

Description

@Focus786

Summary

Feature request: render LaTeX math in messages. When an assistant reply contains
LaTeX delimiters ($...$, $$...$$), the desktop app shows the raw text (backslashes,
underscores, braces) instead of typeset math, which makes any math-heavy answer hard to
read.

Environment

  • opencode version: v2.0.12
  • OS: Microsoft Windows NT 10.0.26200.0 (Windows 11, x64)
  • Terminal: TERM=xterm-256color, TERM_PROGRAM unset, COLORTERM unset
  • Shell: C:\WINDOWS\system32\cmd.exe (opencode shell config: powershell)
  • Install/channel: release (installed via npm, C:\Users<user>\AppData\Roaming\npm\opencode.ps1)
  • Active plugins: ./herdr-opencode (defined in ~/.config/opencode/cli.json)

Reproduction

  1. Ask the agent a question whose answer naturally contains math, e.g.
    write the fixed-point identity: $$p'_{161} = p_{161} + A\,(p_{161} - p_{161}) = p_{161}$$
  2. Read the reply in the OpenCode desktop app.
  3. The message displays the literal source: $$p'_{161} = p_{161} + A\,(p_{161} - p_{161}) = p_{161}$$
    instead of a rendered formula.

Expected Behavior

Inline ($...$) and block ($$...$$) math should render as typeset math, the same way it
does on GitHub / in MathJax- or KaTeX-enabled Markdown readers. If rendering everything by
default is undesirable, a config toggle (for example markdown.math / an inline-math
option) would be enough.

Actual Behavior

The math source is rendered as plain text. $$, \, _, {}, \cdot and friends are all
shown verbatim.

Additional Context

  • This is a feature request, not a bug: the message content is correct Markdown; only the
    rendering layer does not typeset math.
  • I checked the V2 docs (llms.txt, Intro, Web) and found no documented LaTeX/math
    rendering option or toggle, so I'm not missing a setting as far as I can tell.
  • Why it fails today: math is not part of CommonMark/GFM, and typesetting it needs a
    dedicated engine (KaTeX or MathJax) plus math fonts. A plain Markdown renderer therefore
    prints the delimiters as literal text.
  • Likely relevant to other clients too (desktop/TUI/web) if they share the same Markdown
    renderer, but I can only confirm the desktop app.
  • Current workarounds: emit plain-text formulas (p'161 = p161 + A·(p161 − p161) = p161),
    wrap formulas in fenced code blocks, or write formulas into a .md/.pdf and view them
    in a math-capable reader.

Activity

  1. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    This issue doesn’t fully meet our contributing guidelines.

    What needs to be fixed:

    • The title must start with [FEATURE]:.
    • The Feature Request template’s required verification checkbox is missing. Please add it and confirm that you have checked existing requests.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    • #6293: LaTeX/MathJax rendering in the desktop client.
    • #30050: LaTeX rendering in chat/Markdown.
    • #37065: Render LaTeX/math expressions in chat responses.
    • #49486: Raw LaTeX in terminal, with GUI math rendering also requested.

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

  3. Focus786 commented on Sep 26, 2026

    @Focus786
    Author

    Additional evidence: it is not only that math is not typeset — the Markdown renderer also
    corrupts the LaTeX source, so the user cannot even read the raw formula correctly.

    Sent as a standalone message:

    $$p'_{161} = p_{161} + A\,(p_{161} - p_{161}) = p_{161}$$
    

    Displayed in the desktop app (v2.0.12) as literal text:

    $$p'{161} = p{161} + A,(p_{161} - p_{161}) = p_{161}$$
    

    Two changes are visible, both explained by CommonMark/GFM parsing rather than math parsing:

    • p'_{161} → p'{161}: the first two _ are paired as emphasis and consumed, so the
      underscores disappear. The remaining _ are intraword (preceded by a letter) and stay.
    • A\,(...) → A,(...): the backslash escapes ASCII punctuation, so \, renders as ,.

    This happens for a standalone message too, not only when the formula is mixed with prose.
    Inside a fenced code block the source is preserved verbatim, but it is still not typeset.

    Repro (desktop, Windows 11, v2.0.12):

    1. Send a message that contains $$p'_{161} = p_{161} + A\,(p_{161} - p_{161}) = p_{161}$$.
    2. Observe the rendered message: delimiters shown literally, _ eaten as emphasis, \, reduced to ,.

    Expected: either typeset math, or at minimum no silent corruption of the source. Rendering
    math (KaTeX/MathJax) would fix both, but it may also be worth ensuring that math delimiters
    and their contents are excluded from emphasis/escape processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions