Skip to content

Commit 924281e

Browse files
committed
docs($zh): add snippet partial import section
1 parent b854933 commit 924281e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/docs/docs/zh/guide/markdown.md

+25
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,31 @@ module.exports = {
346346
由于代码段的导入将在 webpack 编译之前执行,因此你无法使用 webpack 中的路径别名,此处的 `@` 默认值是 `process.cwd()`
347347
:::
348348

349+
350+
为了只导入对应部分的代码,你也可运用 [VS Code region](https://code.visualstudio.com/docs/editor/codebasics#_folding)。你可以在文件路径后方的 `#` 紧接着提供一个自定义的区域名称(预设为 `snippet`
351+
352+
**输入**
353+
354+
``` md
355+
<<< @/../@vuepress/markdown/__tests__/fragments/snippet-with-region.js#snippet{1}
356+
```
357+
358+
**代码文件**
359+
360+
<!--lint disable strong-marker-->
361+
362+
<<< @/../@vuepress/markdown/__tests__/fragments/snippet-with-region.js
363+
364+
<!--lint enable strong-marker-->
365+
366+
**输出**
367+
368+
<!--lint disable strong-marker-->
369+
370+
<<< @/../@vuepress/markdown/__tests__/fragments/snippet-with-region.js#snippet{1}
371+
372+
<!--lint enable strong-marker-->
373+
349374
## 进阶配置
350375

351376
VuePress 使用 [markdown-it](https://github.com/markdown-it/markdown-it) 来渲染 Markdown,上述大多数的拓展也都是通过自定义的插件实现的。想要进一步的话,你可以通过 `.vuepress/config.js``markdown` 选项,来对当前的 `markdown-it` 实例做一些自定义的配置:

0 commit comments

Comments
 (0)