-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: escape Vue template delimiters in KaTeX rendered output #2347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+3
−2
Conversation
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
✅ Deploy Preview for slidev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
{{ in katex output
kermanx
approved these changes
Nov 14, 2025
@slidev/client
create-slidev
create-slidev-theme
@slidev/parser
@slidev/cli
@slidev/types
commit: |
Copilot
AI
changed the title
fix: escale
Fix: Escape Vue template delimiters in KaTeX rendered output
Nov 14, 2025
{{ in katex output
Copilot finished work on behalf of
kermanx
November 14, 2025 09:50
Member
|
@copilot fix! |
Co-authored-by: kermanx <[email protected]>
Contributor
Author
Copilot finished work on behalf of
kermanx
November 14, 2025 09:55
antfu
approved these changes
Nov 18, 2025
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.
Fix for {{ inside Math Causing Errors ✅
Issue: Consecutive
{{inside LaTeX math expressions were being interpreted by Vue as template interpolation delimiters, causing parsing errors.Solution: Applied the existing
escapeVueInCodeutility function to both inline and block KaTeX rendering output. This function replaces{{with{{which prevents Vue from interpreting the braces as template interpolation delimiters while preserving the correct rendering of the math expressions.Changes made:
escapeVueInCodeinmarkdown-it-katex.tsFiles Changed:
packages/slidev/node/syntax/markdown-it/markdown-it-katex.ts- Added escaping to KaTeX outputtest/katex.test.ts- Added test case for double braces in math expressions (fixed to use actual{{instead of escaped\{\{)Testing:
{{in LaTeX expressions (e.g.,${{\\alpha}}^T$){{is escaped to{{in the outputFixes #2240
Original prompt
This section details on the original issue you should resolve
<issue_title>{{ inside math causes unclear errors</issue_title>
<issue_description>Describe the bug
Consecutive
{{inside LaTeX math expressions cause several kinds of unclear error messages.Workaround: Adding a space between consecutive braces helps, e.g.
${ {\alpha}^i}^T$then LaTeX renders fine.Minimal reproduction
Steps to reproduce the behavior:
${{\alpha}}^T$in slides.md and save. Note open {{ AND closing }}.=> Shows error (may take a second or two until it pops up):
(The important part is "Error parsing JavaScript expression". The detail about "\uXXXX" is specific to \alpha and may vary per math expression. A simple expression like
${{x}}$can work with no error! But e.g.${{x-}}$fails becausex-is invalid as JS.)${{\alpha}^i}^T$, note {{ BUT no closing }}, it shows different error:(Looks like the KaTeX render succeeds, it seems it's only the
<annotation encoding="application/x-tex">{{\alpha}^i}^T</annotation>tag that triggers issue?Guess: is it intercepted by some Vue template syntax?)
Environment
Slidev version: 52.1.0
Browser: Firefox 141
OS: Linux
reproduced in a local project (i.e.
npm create slidev@latest).</issue_description>
<agent_instructions>In MarkdownItKatex, before returning rendered text, you should escape
{{using the existingescapeVueInCode. e.g.escapeVueInCode(katex.renderToString(...))</agent_instructions>Comments on the Issue (you are @copilot in this section)
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.