Skip to content

Commit

Permalink
fix(markdown): render token attrs in code block (#1220)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Dec 30, 2022
1 parent 5f3bbee commit b4e313b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/markdown/src/plugins/codePlugin/codePlugin.ts
Expand Up @@ -75,10 +75,12 @@ export const codePlugin: PluginWithOptions<CodePluginOptions> = (
options.highlight?.(token.content, language.name, '') ||
md.utils.escapeHtml(token.content)

token.attrJoin('class', languageClass)

// wrap highlighted code with `<pre>` and `<code>`
let result = code.startsWith('<pre')
? code
: `<pre class="${languageClass}"><code>${code}</code></pre>`
: `<pre${slf.renderAttrs(token)}><code>${code}</code></pre>`

// resolve v-pre mark from token info
const useVPre = resolveVPre(info) ?? vPreBlock
Expand Down

0 comments on commit b4e313b

Please sign in to comment.