Skip to content

Commit 5d331b3

Browse files
Copilotkermanxautofix-ci[bot]
authored
fix: escape Vue template delimiters in KaTeX rendered output (#2347)
Co-authored-by: kermanx <63178754+kermanx@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: _Kerman <kermanx@qq.com>
1 parent a10be9e commit 5d331b3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/slidev/node/syntax/markdown-it/markdown-it-katex.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ for rendering output.
1111

1212
import type { KatexOptions } from 'katex'
1313
import katex from 'katex'
14+
import { escapeVueInCode } from '../transform/utils'
1415

1516
// Test if potential opening or closing delimiter
1617
// Assumes that there is a "$" at state.src[pos]
@@ -167,7 +168,7 @@ export default function MarkdownItKatex(md: any, options: KatexOptions) {
167168
const katexInline = function (latex: string) {
168169
options.displayMode = false
169170
try {
170-
return katex.renderToString(latex, options)
171+
return escapeVueInCode(katex.renderToString(latex, options))
171172
}
172173
catch (error) {
173174
if (options.throwOnError)
@@ -184,7 +185,7 @@ export default function MarkdownItKatex(md: any, options: KatexOptions) {
184185
const katexBlock = function (latex: string) {
185186
options.displayMode = true
186187
try {
187-
return `<p>${katex.renderToString(latex, options)}</p>`
188+
return `<p>${escapeVueInCode(katex.renderToString(latex, options))}</p>`
188189
}
189190
catch (error) {
190191
if (options.throwOnError)

0 commit comments

Comments
 (0)