Skip to content

VitePress中的Markdown扩展功能

更新时间: 2025-01-17T00:00:00.000Z

技术分享
Markdown
VitePress

VitePress中的Markdown扩展功能

在使用VitePress搭建博客时,了解其内置的Markdown扩展功能是非常有帮助的。本文将详细介绍一些常用的扩展功能。

语法高亮

VitePress提供由 Shiki 驱动的语法高亮,还具有行高亮等附加功能:

示例代码

md
```js{4}
export default {
  data () {
    return {
      msg: 'Highlighted!'
    }
  }
}
```

Output

js
export default {
  data () {
    return {
      msg: 'Highlighted!'
    }
  }
}

Custom Containers

Input

md
::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details
This is a details block.
:::

Output

INFO

This is an info box.

TIP

This is a tip.

WARNING

This is a warning.

DANGER

This is a dangerous warning.

Details

This is a details block.

More

Check out the documentation for the full list of markdown extensions.

Released under the MIT License.