Skip to content

Commit ec92d7a

Browse files
authored
fix: allow more characters for slot names (#1209)
1 parent 46aac03 commit ec92d7a

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

packages/slidev/node/plugins/markdown.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export function transformSlotSugar(md: string) {
144144
if (isLineInsideCodeblocks(idx))
145145
return
146146

147-
const match = line.trimEnd().match(/^::\s*(\w+)\s*::$/)
147+
const match = line.trimEnd().match(/^::\s*([\w\.\-\:]+)\s*::$/)
148148
if (match) {
149149
lines[idx] = `${prevSlot ? '\n\n</template>\n' : '\n'}<template v-slot:${match[1]}="slotProps">\n`
150150
prevSlot = true

test/__snapshots__/transform.test.ts.snap

+20
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,25 @@ Right Slot
103103
Default Slot
104104
105105
106+
</template>"
107+
`;
108+
109+
exports[`markdown transform > slot-sugar with symbols in name 1`] = `
110+
"
111+
# Page
112+
113+
Default Slot
114+
115+
<template v-slot:slot::1=\\"slotProps\\">
116+
117+
First Slot
118+
119+
120+
</template>
121+
<template v-slot:slot.2=\\"slotProps\\">
122+
123+
Second Slot
124+
125+
106126
</template>"
107127
`;

test/transform.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ Slot Usage
4545
::left::
4646
\`\`\`
4747
48+
`)).toMatchSnapshot()
49+
})
50+
51+
it('slot-sugar with symbols in name', () => {
52+
expect(transformSlotSugar(`
53+
# Page
54+
55+
Default Slot
56+
::slot::1::
57+
First Slot
58+
::slot.2::
59+
Second Slot
4860
`)).toMatchSnapshot()
4961
})
5062

0 commit comments

Comments
 (0)