Repository navigation
Replies: 2 comments
|
The reported behavior is consistent with the Markdown math parser treating single dollar signs as inline-math delimiters, even when they are intended to represent currency. I'd address this in the renderer rather than modifying the assistant's generated text. For example, if the renderer uses math({
singleDollarTextMath: false
})This would allow ordinary text containing currency values to remain ordinary text instead of being parsed as a mathematical expression. However, it could affect documents that intentionally use single-dollar delimiters for inline mathematics, so the change should be covered by regression tests. I'd test at least these cases:
The exact option should be verified against the installed extension version. If the project intentionally supports single-dollar mathematics, an alternative is to improve delimiter recognition so currency text isn't mistaken for math. |
Uh oh!
There was an error while loading. Please reload this page.
Upstream bug report: single-dollar inline math swallows dollar amounts in prose
Package:
@deepseek-ai/dsh-client-ui-primitives(markdown renderer)Severity: high for agent-output readability — money amounts and other
$-bearing prose are silently destroyedEnvironment observed: DSH Desktop 0.x (shipped app.asar, Sep 29 build), dark theme, macOS
Summary
parseGfmWithMath()registers the TeX math extension without options:micromark-extension-mathdefaultssingleDollarTextMath: truewhen unset(confirmed in the shipped vendor bundle:
let n={}.singleDollarTextMath; n==null&&(n=!0)).So a pair of
$characters anywhere in a paragraph opens an inline-math node.Repro
Assistant output containing dollar amounts:
The
$in$3,641and the$in$200/moare consumed as inline-mathdelimiters. Everything between them —
3,641** *in Sonnet — equivalent API terms* (18,206 Opus-equivalent) — a— is handed to KaTeX and typeset as math:**/*render as literal centered asterisksVerified live: an assistant message rendered the sentence as
**3, 641** *inSonnet—equivalentAPIterms*inside a KaTeX span, with$200/mo Max plan covers 0.8 dayscontinuing as plain text after it.Why the existing guard does not catch it
renderTexToReactrenders withthrowOnError: trueand falls back tothrowOnError: falseon failure. Dollar-amount prose parses as valid TeX, soboth paths "succeed" and the mangling is rendered without any error marker.
Suggested fixes (any one of these)
Disable single-dollar text math (recommended default for a chat/agent
renderer, matches Claude Desktop / ChatGPT behavior):
$$…$$display math and\(…\)/\[…\]keep working via the existingmathCompatibility()extension.Gate dollar-math behind a user setting, defaulting off.
If single-dollar math must stay, require currency-hostile context before
opening a math span (e.g. the opening
$must not be followed by a digit,or must be preceded by whitespace AND followed by a non-space non-digit) —
this is what other chat renderers do to avoid exactly this failure.
Local mitigation shipped meanwhile
A client plugin (
@local/dsh-readability) detects renderedspan.katexelements whose
annotation[encoding="application/x-tex"]source is prose(contains
**, or*without any\command, or ≥4 word-like tokens) andswaps them back to plain text with the consumed
$delimiters restored. Itnever touches TeX containing backslash commands.
All reactions