fix: durable KaTeX rendering fix — dedupe marked + CSS safety net#505
Merged
fix: durable KaTeX rendering fix — dedupe marked + CSS safety net#505
Conversation
Root cause: markdown-block (from mini-lit) bundles its own marked@16 while our safety patch targets the root marked@17. Two separate module instances → our installMarkedSafetyPatch() never intercepts the markdown-block's .use() calls → KaTeX extensions register freely → formula text with \(...\) renders as serif italic math. Three-layer defense: 1. Vite resolve.dedupe for 'marked' — forces all imports to the same instance so our safety patch covers markdown-block too. Test added to catch removal. 2. CSS safety net — markdown-block .katex, .katex * get forced to var(--font-sans) !important. Even if KaTeX somehow renders, it won't produce serif/italic text. 3. Policy (existing) — DISABLED_MARKDOWN_EXTENSION_NAMES still strips all four math extensions from .use() calls.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
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
KaTeX serif/italic font rendering keeps coming back in thinking blocks despite the #486 fix. Formula text with
\(...\)patterns renders as math.Root cause
markdown-block(from@mariozechner/mini-lit) bundles its ownmarked@16.4.2while our safety patch targets the rootmarked@17.0.4. Two separate module instances = ourinstallMarkedSafetyPatch()never interceptsmarkdown-block's.use()calls.Fix — three-layer defense
resolve.dedupe: ["marked"]markdown-block .katex { font-family: var(--font-sans) !important }DISABLED_MARKDOWN_EXTENSION_NAMES.use()Added a
test:modelstest that verifies the dedupe config stays invite.config.ts.Testing
npm run build✅npm run test:models✅ (19/19, includes new dedupe test)npm run test:security✅ (45/45)npm run test:context✅ (640/640)