zai-org / zai-org/feedback

[Bug] ZCode markdown renderer: Single-$ math mode corrupts text with dollar signs

Open
#232 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Bug Description

ZCode chat markdown renderer incorrectly interprets $ characters as math delimiters, converting normal text (currency, variables, prices) into KaTeX math expressions.


Problem Behavior

What Happens:
  1. User types text containing $ (currency, variable names, etc.)
  2. ZCode uses single-dollar inline math (micromark-extension-math + KaTeX)
  3. Every pair of $ opens/closes a math span
  4. Text between $ becomes: italic serif, collapsed spacing, eaten line breaks
Example:
Input:  "Cost is $50 for one and $100 for two"
Output: "50 for one and" renders as MATH expression!

Technical Root Cause

  • File: resources\app.asar → out\renderer\assets\styles-BvByAfPm.js
  • Config: math: gT({singleDollarTextMath:!0}) — hardcoded to TRUE
  • Problem: No settings toggle exists to disable this
  • Search: This string appears exactly ONCE in entire app as config

Impact Severity

Reporter tested against actual session transcript:

"Nearly every paragraph and table row had multiple math spans, some swallowing 30–60 words of prose"

Metric Finding
Paragraphs affected Nearly every one
Table rows affected Nearly every row
Max words swallowed 30-60 words per span
Affected Content Types:
  • Currency: "$50", "$100", "$29.99"
  • Variables: "$var", "$user.name", ${expr}
  • Prices in tables
  • Shell code / terminal output
  • Any text with $ character

Why Critical for ZCode Users

  1. Developers use $ constantly — PHP, shell vars, JS template literals
  2. Code discussions break — Variable names become math
  3. Technical writing corrupted — Pricing, budgets, configs
  4. Unpredictable — Cannot easily predict what triggers math mode
  5. No workaround — No setting to disable it

Suggested Fixes

Option A: Disable Single-Dollar Math (Recommended)
// Change hardcoded config:
math: gT({singleDollarTextMath: false})  // Require $$ instead
Option B: Add Settings Toggle
Settings → Editor → Markdown Rendering
☐ Enable single-dollar inline math ($...$)
☑ Use double-dollar only ($$...$$) [safer]
Option C: Smarter Heuristic

Only treat as math if content looks like math (no spaces, short, math-like chars only).

Option D: Escape Mechanism

Allow \$50 to render as literal $50.


Reproduction Steps

  1. Open ZCode
  2. Send message: "The price is $50 or $100"
  3. Observe: Text between $ signs becomes italic math
  4. Try table: | Cost | $50 | → Formatting breaks

Reporter Info

  • Source: Discord
  • Reporter: Luke (OP)
  • Timestamp: Yesterday at 4:38 AM
  • Technical Level: Advanced (analyzed app.asar source)

Severity: P1 High

  • Silent data corruption of output text
  • Affects nearly all text with $ characters
  • No user workaround available
  • Particularly bad for developers (primary users)

Labels Suggested:

bug, markdown, renderer, math, katex, zcode, text-corruption


Submitted by:
Regards,
Roman (Discord: bignavi_x)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the renderer configuration in resources\app.asar → out\renderer\assets\styles-BvByAfPm.js and confirm the single occurrence of math: gT({singleDollarTextMath:!0}). Reproduce the issue with “The price is $50 or $100” and a table containing $50; done means literal dollar-sign text renders normally while the selected math-delimiter behavior is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.