Skip to content

Commit 1f2e2eb

Browse files
committed
chore(playground): fix markdown rendering issues
- Remove duplicate markdown-body wrapper from unplugin-vue-markdown - Wrap tables in scrollable container to prevent overflow-x - Open external links in new window - Remove unsupported [!TIP] callout from intro
1 parent 1985178 commit 1f2e2eb

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

apps/playground/src/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
padding: 0.5rem 1rem;
8686
}
8787
88+
> .overflow-x-auto {
89+
margin-bottom: 1rem;
90+
}
91+
8892
table {
8993
width: 100%;
9094
background-color: var(--v0-surface);

apps/playground/src/content/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The editor ships a complete single-file component setup. Your `App.vue` runs ins
1111
- **UnoCSS runtime** with `presetWind4` (Tailwind v4 syntax) loaded automatically — no config needed
1212
- **`createThemePlugin`** installed with `light` and `dark` themes; every theme color is defined and reactive to theme switches
1313

14-
> [!TIP] Theme colors work two ways: CSS custom properties (`var(--v0-primary)`) and UnoCSS utilities (`text-primary`, `bg-surface`, `border-divider`). Use the utilities — they're shorter and theme-aware by default.
14+
Theme colors work two ways: CSS custom properties (`var(--v0-primary)`) and UnoCSS utilities (`text-primary`, `bg-surface`, `border-divider`). Use the utilities — they're shorter and theme-aware by default.
1515

1616
## Composables
1717

apps/playground/vite.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,29 @@ async function createMarkdownPlugin () {
3434
})
3535

3636
return Markdown({
37+
wrapperClasses: '',
3738
markdownItSetup (md) {
3839
md.use(
3940
fromHighlighter(highlighter as HighlighterGeneric<BundledLanguage, BundledTheme>, {
4041
themes: SHIKI_THEMES,
4142
defaultColor: false,
4243
}),
4344
)
45+
46+
// Wrap tables in scrollable container
47+
md.renderer.rules.table_open = () => '<div class="overflow-x-auto mb-4"><table>'
48+
md.renderer.rules.table_close = () => '</table></div>'
49+
50+
// Open external links in new window
51+
md.renderer.rules.link_open = (tokens, index, options, _env, self) => {
52+
const token = tokens[index]
53+
const href = token.attrGet('href') || ''
54+
if (/^https?:\/\//i.test(href)) {
55+
token.attrSet('target', '_blank')
56+
token.attrSet('rel', 'noopener noreferrer')
57+
}
58+
return self.renderToken(tokens, index, options)
59+
}
4460
},
4561
})
4662
}

0 commit comments

Comments
 (0)