Repository navigation
fix(documents): rescue dollar-delimited math in AI-written HTML - #838
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The document write path parses model HTML through parseDocumentAiHtml, which rescues sub/sup but never math. Math written as `$…$` or `$$…$$` was stored as literal text, so generated notes showed plain-text formulas. Add a deterministic rescue beside the sub/sup handling in rewriteLossyElements: convert `$…$` into inline math nodes and `$$…$$` into block math nodes. Skip code, pre, widget source, and existing math nodes, and leave plain money like `$5 and $10` alone by reusing the mathLikeInlineBody heuristic. Move mathLikeInlineBody to a neutral module (src/lib/math-like-text.ts) so the document model does not import from the chat UI folder. Flashcards and quizzes share parseDocumentAiHtml, so they get the same rescue. Generated-By: PostHog Desktop Task-Id: 194509e0-b536-46b2-a3e3-39b8ed77620d
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
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.
Problem
parseDocumentAiHtmlrescues<sub>/<sup>andh5/h6, but nothing repairs math. Math the model writes as$…$or$$…$$is stored as literal text; only display equations already in their own math block survived.Changes
rewriteLossyElements, beside the existingsub/suphandling, converts dollar-delimited math into the math nodes the schema renders.$E = mc^2$<span data-type="inline-math">)$$\int_0^1 x^2 dx$$<div data-type="block-math">)$5 and $10, prosemathLikeInlineBodyguards money)<code>,<pre>, widget source$$…$$pair is display math with no money reading, so a non-empty body is enough.mathLikeInlineBodyheuristic to a neutral module (src/lib/math-like-text.ts) shared by the chat Markdown normalizer and the document parser, so the document model no longer imports from the chat UI folder.parseDocumentAiHtml, so they get the rescue too.Testing
pnpm check(format, lint, types) — pass.pnpm vitest --runover documents, content, flashcards, quizzes — 81 pass.Closes #837
Created with PostHog Desktop from this inbox report, addressing #837.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.