Skip to content

Commit d27b515

Browse files
zzxmingantfu
andauthored
fix(vitepress-twoslash): empty twoslash error at end of the line (#999)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 5364201 commit d27b515

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/vitepress-twoslash/src/renderer-floating-vue.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ function renderMarkdownInline(this: ShikiTransformerContextCommon, md: string, c
173173
}
174174

175175
function compose(parts: { token: Element | Text, popup: Element }): Element[] {
176+
if (parts.token.type === 'element' && parts.token.children.length < 1) {
177+
const classes = parts.token.properties.class || ''
178+
parts.token.properties.class = `${classes} twoslash-error-empty`
179+
}
180+
176181
return [
177182
{
178183
type: 'element',

packages/vitepress-twoslash/src/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,11 @@
141141
.twoslash-floating.twoslash-completion .twoslash-completion-list li {
142142
padding: 3px 0;
143143
}
144+
145+
.twoslash-error:empty,
146+
.twoslash-error-empty {
147+
display: inline-block;
148+
min-width: 0.55em;
149+
min-height: 1.2em;
150+
vertical-align: middle;
151+
}

0 commit comments

Comments
 (0)