mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-10-19 17:23:18 +00:00
* 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>
|
||
|---|---|---|
| .. | ||
| public | ||
| src | ||
| test-results | ||
| .gitignore | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| components.json | ||
| eslint.config.mjs | ||
| next.config.ts | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.mjs | ||
| start-server.js | ||
| tsconfig.json | ||
| vitest.config.ts | ||