Skip to content

How to solve escaping of inline code blocks #3724

Closed Answered by brc-dd
oeyoews asked this question in Q&A
Discussion options

You must be logged in to vote

If you don't want to use vue interpolation in inline code anywhere, you can add something like this to your config:

import { defineConfig } from 'vitepress'

export default defineConfig({
  markdown: {
    config(md) {
      const defaultCodeInline = md.renderer.rules.code_inline!
      md.renderer.rules.code_inline = (tokens, idx, options, env, self) => {
        tokens[idx].attrSet('v-pre', '')
        return defaultCodeInline(tokens, idx, options, env, self)
      }
    }
  }
})

Then simply use it like you'd normally have:

`{{ foo }}`

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@oeyoews
Comment options

Answer selected by oeyoews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants