Repository navigation
Conversation
Render explicit $...$ and $$...$$ formulas in the learner's own chat bubbles with KaTeX when they enable Appearance -> Chat messages -> Math in my messages. The preference is off by default and stored locally. Only explicit math delimiters are interpreted; prose, code spans/fences, prices and the content sent to the model stay untouched.
Replace the lookbehind regexes with a delimiter scanner, guard non-string content, and wrap the optional renderer in an error boundary that falls back to literal text.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
User messages in chat are rendered as literal text while assistant replies go through Markdown/KaTeX. When a learner writes a formula, they see the raw
$...$source in their own bubble.This adds an opt-in, math-only renderer for sent user messages:
$...$and$$...$$delimiters are rendered with KaTeX.$5 和 $10,$5-$10) and$PATHstay literal.The preference is a browser-local display setting (global across sessions on that browser). Keeping it out of the server settings contract keeps this change small; it can be promoted to
UiSettingslater if cross-device sync is wanted.Related Issues
Module(s) Affected
web(Frontend)testsChecklist
dev.Additional Notes
tests/user-message-math.spec.tsx(segmentation, prices/code staying literal, KaTeX rendering, and the bubble switching when the preference changes).npm run test:unit -- tests/user-message-math.spec.tsx,npm run test:unit -- tests/consultation-message-reference.spec.tsx tests/partner-archives-markdown.spec.tsx,npm run typecheck,npx eslinton the changed files,npm run architecture:check,npm run i18n:parity,npm run i18n:audit.pre-commitis not installed in this environment, so the equivalent checks above were run directly.