Skip to content

fix(ui): digit-led single-$ inline math renders raw in chat #375

Closed

Description

@aarontrowbridge

Render digit-led single-$ inline math in chat

Important

Problem — The chat markdown renderer's guarded single-$ inline-math rule rejects any math whose opening $ is immediately followed by a digit (a currency false-positive guard). All digit-led inline math — the single most common physics reporting shape, e.g. $3.53\times10^{-5}$, $10^{-5}$, $F = 0.99$-style values starting with a number — falls through to markdown and renders as raw text. Non-digit math ($\alpha$) renders fine, which is why the failure looked random.
Approach — Move the digit guard from the open side of the delimiter to the close side: the opening $ keeps the no-space/no-$$ guards but drops the no-digit one; the closing $ additionally must not be followed by a digit. This is Pandoc's actual currency rule ("the closing $ must not be followed by a digit") and it holds every existing guard case (tight pairs like $30-and-$50 stay literal because the first closing $ is followed by a digit) while letting digit-led math through.

Acceptance Criteria

  • $3.53\times10^{-5}$ and $3.1\times10^{-3}$ inside prose render as KaTeX inline math
  • Currency stays literal: $5 and $10, tight $30-and-$50 pairs
  • Env-var dollars ($HOME, $PATH), escaped \$, halves of $$…$$, and code spans all stay literal
  • The three delimiter-shape regexes (tokenizer, global replace; start hint unchanged) stay in one family

Testing Decisions

Extend the existing markdown-math suite for the marked renderer with: the two digit-led shapes above as positive cases, and a tight digit-pair currency case as a negative case.

Notes

Fix follows the overlay extraction path: after merge, the app-bundle overlay is re-extracted at the new fork tag so the drift gate stays green. User-reported instance: infidelity floors quoted as ($3.53\times10^{-5}$ — …) rendered raw in chat.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    hitlNeeds a human decision/review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions