Skip to content

Commit

Permalink
fix: disable code interop in inline code, fix #1540 (#1546)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 17, 2024
1 parent 60ce54f commit e8a14c7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/slidev/node/vite/markdown.ts
Expand Up @@ -120,6 +120,7 @@ export async function createMarkdownPlugin(
},
})

md.use(MarkdownItEscapeInlineCode)
md.use(MarkdownItFootnote)
md.use(MarkdownItTaskList, { enabled: true, lineNumber: true, label: true })
md.use(MarkdownItKatex, KatexOptions)
Expand Down Expand Up @@ -167,3 +168,11 @@ export async function createMarkdownPlugin(
},
}) as Plugin
}

function MarkdownItEscapeInlineCode(md: MarkdownIt) {
const codeInline = md.renderer.rules.code_inline!
md.renderer.rules.code_inline = (tokens, idx, options, env, self) => {
const result = codeInline(tokens, idx, options, env, self)
return result.replace(/^<code/, '<code v-pre')
}
}

0 comments on commit e8a14c7

Please sign in to comment.