Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin-md-power): add demo syntax #415

Merged
merged 14 commits into from
Jan 10, 2025
Merged

feat(plugin-md-power): add demo syntax #415

merged 14 commits into from
Jan 10, 2025

Conversation

pengzhanbo
Copy link
Owner

@pengzhanbo pengzhanbo commented Jan 5, 2025

Warning

此 PR 处于 试验性研究 阶段

描述

增加新的 嵌入语法 和 容器语法 以 支持向 markdown 中 插入 代码演示:

  • normal: 普通前端代码演示, html + js/ts + css/less/sass/stylus
  • vue: vue 组件代码演示, .vue 或者 .ts/.js + csscss/less/sass/stylus
  • markdown: markdown 代码演示

此功能用于代替 vuepress-plugin-md-enhance 中的 demo 功能。
该插件对于 demo 功能的实现,基于实际的使用场景的实践,与预期不符合,因此重新进行设计。

嵌入语法

<!-- 普通前端代码 -->
@[demo](./xxx.html)
@[demo title="示例" desc="示例描述"](./xxx.html)

<!-- vue 组件 -->
@[demo vue](./xxx.vue)
@[demo vue title="示例" desc="示例描述"](./xxx.vue)
@[demo vue](./xxx.ts)
@[demo vue](./xxx.js)

<!-- markdown -->
@[demo markdown](./xxx.md)
@[demo markdown title="示例" desc="示例描述"](./xxx.md)

容器语法

::: demo vue
```vue
vue code
```
:::

:::demo vue title="示例" desc="示例描述"
```vue
vue code
```
:::

:::: demo vue
::: code-tabs
@tab Component.ts
```ts/js
import { defineComponent } from 'vue'

export default defineComponent({
  // code
})
```
@tab style.css
```css/less/scss/stylus
styles code
```
:::
::::

此语法在 node 编译时预处理组件,不需要在 浏览器运行时额外加载如 babel 等依赖。


预览

普通前端代码演示

QQ_1736315992082

vue 组件代码演示

QQ_1736081197767

@pengzhanbo pengzhanbo marked this pull request as ready for review January 9, 2025 00:28
@pengzhanbo pengzhanbo merged commit a9f6bd0 into main Jan 10, 2025
2 checks passed
@pengzhanbo pengzhanbo deleted the demo-syntax branch January 10, 2025 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant