Skip to content

Commit bc7271d

Browse files
authoredSep 1, 2024··
feat: add data-title attribute for code group label tag (#4152)
1 parent 0db269a commit bc7271d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/node/markdown/plugins/containers.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const containerPlugin = (
4848
render: (tokens: Token[], idx: number) =>
4949
tokens[idx].nesting === 1 ? `<div class="vp-raw">\n` : `</div>\n`
5050
})
51-
.use(...createCodeGroup(options))
51+
.use(...createCodeGroup(options, md))
5252
}
5353

5454
type ContainerArgs = [typeof container, string, { render: RenderRule }]
@@ -79,7 +79,7 @@ function createContainer(
7979
]
8080
}
8181

82-
function createCodeGroup(options: Options): ContainerArgs {
82+
function createCodeGroup(options: Options, md: MarkdownIt): ContainerArgs {
8383
return [
8484
container,
8585
'code-group',
@@ -111,7 +111,7 @@ function createCodeGroup(options: Options): ContainerArgs {
111111

112112
if (title) {
113113
const id = nanoid(7)
114-
tabs += `<input type="radio" name="group-${name}" id="tab-${id}" ${checked}><label for="tab-${id}">${title}</label>`
114+
tabs += `<input type="radio" name="group-${name}" id="tab-${id}" ${checked}><label data-title="${md.utils.escapeHtml(title)}" for="tab-${id}">${title}</label>`
115115

116116
if (checked && !isHtml) tokens[i].info += ' active'
117117
checked = ''

0 commit comments

Comments
 (0)
Please sign in to comment.