Skip to content

Commit

Permalink
feat: support vitepress's code snippet import (#3559)
Browse files Browse the repository at this point in the history
  • Loading branch information
so1ve committed Sep 15, 2023
1 parent 2c74284 commit 323938b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vue-language-core/src/plugins/file-md.ts
Expand Up @@ -9,6 +9,7 @@ const scriptSetupReg = /\\\<[\s\S]+?\>\n?/g;
const sfcBlockReg = /\<(script|style)\b[\s\S]*?\>([\s\S]*?)\<\/\1\>/g;
const angleBracketReg = /\<\S*\:\S*\>/g;
const linkReg = /\[[\s\S]*?\]\([\s\S]*?\)/g;
const codeSnippetImportReg = /^\s*<<<\s*.+/gm;

const plugin: VueLanguagePlugin = () => {

Expand All @@ -26,7 +27,9 @@ const plugin: VueLanguagePlugin = () => {
// inline code block
.replace(inlineCodeblockReg, match => `\`${' '.repeat(match.length - 2)}\``)
// # \<script setup>
.replace(scriptSetupReg, match => ' '.repeat(match.length));
.replace(scriptSetupReg, match => ' '.repeat(match.length))
// <<< https://vitepress.dev/guide/markdown#import-code-snippets
.replace(codeSnippetImportReg, match => ' '.repeat(match.length));

const codes: Segment[] = [];

Expand Down
1 change: 1 addition & 0 deletions packages/vue-test-workspace/syntax/snippet-import.md
@@ -0,0 +1 @@
<<<

0 comments on commit 323938b

Please sign in to comment.