Skip to content

Commit b4e313b

Browse files
authored
fix(markdown): render token attrs in code block (#1220)
1 parent 5f3bbee commit b4e313b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/markdown/src/plugins/codePlugin/codePlugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ export const codePlugin: PluginWithOptions<CodePluginOptions> = (
7575
options.highlight?.(token.content, language.name, '') ||
7676
md.utils.escapeHtml(token.content)
7777

78+
token.attrJoin('class', languageClass)
79+
7880
// wrap highlighted code with `<pre>` and `<code>`
7981
let result = code.startsWith('<pre')
8082
? code
81-
: `<pre class="${languageClass}"><code>${code}</code></pre>`
83+
: `<pre${slf.renderAttrs(token)}><code>${code}</code></pre>`
8284

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

0 commit comments

Comments
 (0)