open-notebook/frontend
Cory Potter cc5af65473
fix(frontend): silence noisy KaTeX warning on Unicode symbols in math spans (#1208)
* fix(frontend): silence noisy KaTeX warning on Unicode symbols

AI-generated content often contains Unicode punctuation (en/em dashes,
smart quotes) inside single-dollar math spans, e.g. a price range like
"$5 – $10". Models legitimately emit inline math as $...$ per this
project's own prompts ("MATH FORMATTING" sections), so remark-math
correctly reads it as math - but KaTeX's default strict mode then logs
a console warning for every character outside its symbol table.

The warning is harmless (KaTeX still renders a best-effort glyph) but
noisy: 66+ occurrences in a few days of normal use on one deployment.

Fix: pass KaTeX's own `strict` option as a function that ignores only
the `unknownSymbol` error code, leaving every other strict check (e.g.
deprecated commands) at its default. All three markdown-rendering call
sites (chat/insight/source rendering, the note editor live preview,
and the transformation playground) now share one KATEX_OPTIONS
constant instead of duplicating the same override three times.

Verified: 140/140 frontend tests pass (including the existing test
that asserts single-dollar inline math still renders via KaTeX),
tsc --noEmit clean, eslint clean (0 errors), production build clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* address review: lock down unknownSymbol suppression with tests

Per cubic's review on this PR:
- Add a regression test asserting the em/en-dash-in-price-range
  pattern that motivated this fix produces no [unknownSymbol] warning,
  and a second test asserting a different strict violation
  ([commentAtEnd]) is still warned on - proving the ignore is scoped
  to exactly one error code, not silently widened.
- Reword the KATEX_OPTIONS comment: suppressing unknownSymbol isn't
  purely cosmetic. KaTeX's own parser falls back unrecognized
  codepoints to mode: 'text' rather than proper math-mode metrics, so
  an ignored symbol can render with approximated spacing rather than a
  real glyph. Acceptable for stray punctuation, not a blanket license
  to route arbitrary Unicode through math mode.

Verified: 142/142 frontend tests pass (up from 140 - the two new
tests), tsc --noEmit clean, eslint clean (0 errors).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Luis Novo <lfnovo@gmail.com>
2026-10-03 01:19:46 +00:00
..
public Version 1 (#160) 2025-10-18 12:46:22 -03:00
src fix(frontend): silence noisy KaTeX warning on Unicode symbols in math spans (#1208) 2026-10-03 01:19:46 +00:00
test-results feat(i18n): add Turkish (tr-TR) translation (#871) 2026-06-13 08:46:15 -03:00
.gitignore chore: export docs for custom gpt 2025-10-18 20:26:11 -03:00
AGENTS.md chore(frontend): typed locales, drop unused deps, fix AGENTS.md drift (#1061) 2026-07-11 18:45:57 -03:00
CLAUDE.md docs: restructure documentation around AGENTS.md, VISION.md and decision records (#1032) 2026-07-10 15:33:19 -03:00
components.json Version 1 (#160) 2025-10-18 12:46:22 -03:00
eslint.config.mjs Version 1 (#160) 2025-10-18 12:46:22 -03:00
next.config.ts refactor: rename "API Keys" settings page to "Models" (#1313) 2026-09-05 13:20:20 -03:00
package-lock.json chore(deps): security update for frontend and Python dependencies (#1404) 2026-10-03 01:07:22 +00:00
package.json chore(deps): security update for frontend and Python dependencies (#1404) 2026-10-03 01:07:22 +00:00
postcss.config.mjs Version 1 (#160) 2025-10-18 12:46:22 -03:00
start-server.js fix: use Node.js wrapper for cross-platform PORT fallback 2026-01-14 22:51:39 -03:00
tsconfig.json Feat/localization tests docker (#371) 2026-01-15 13:51:05 -03:00
vitest.config.ts fix: make validate_url() async so DNS resolution doesn't block the event loop (#1011) 2026-07-10 10:43:36 -03:00