docs: update code block features

This commit is contained in:
pengzhanbo 2025-04-28 20:19:30 +08:00
parent a35ac8eae8
commit 6ca72d08ef

View File

@ -218,6 +218,23 @@ export default {
}
```
::: tip 在不同的语言代码块中,应该使用该语言的有效的行注释语法
比如在 bash 代码块中,应该使用 `# [!code focus]`
````md
```bash
mkdir hello && cd hello # [\!code focus]
pnpm install
```
````
```bash
mkdir hello && cd hello # [!code focus]
pnpm install
```
:::
## 代码块中的颜色差异
在某一行添加 `// [!code --]``// [!code ++]` 注释将会为该行创建 diff同时保留代码块的颜色。
@ -250,6 +267,21 @@ export default {
}
```
::: tip 在不同的语言代码块中,应该使用该语言的有效的行注释语法
比如在 bash 代码块中,应该使用 `# [!code ++]`
````md
```bash
mkdir hello && cd hello # [\!code ++]
```
````
```bash
mkdir hello && cd hello # [!code ++]
```
:::
## 高亮“错误”和“警告”
在某一行添加 `// [!code warning]``// [!code error]` 注释将会为该行相应的着色。
@ -282,6 +314,21 @@ export default {
}
```
::: tip 在不同的语言代码块中,应该使用该语言的有效的行注释语法
比如在 bash 代码块中,应该使用 `# [!code warning]`
````md
```bash
mkdir hello && cd hello # [\!code warning]
```
````
```bash
mkdir hello && cd hello # [!code warning]
```
:::
## 代码块中 词高亮
**输入:**
@ -326,6 +373,21 @@ options.foo = 'baz'
console.log(options.foo) // 这个不会被高亮显示
```
:::tip 在不同的语言代码块中,应该使用该语言的有效的行注释语法
比如在 bash 代码块中,应该使用 `# [!code word:hello]`
````md
```bash
mkdir hello && cd hello # [\!code word:hello]
```
````
```bash
mkdir hello && cd hello # [!code word:hello]
```
:::
## 代码块中的 空白符
将空白字符Tab 和空格)渲染为可见状态。