@@ -10,10 +10,10 @@ const codeblockReg = /(`{3,})[\s\S]+?\1/g;
1010const inlineCodeblockReg = / ` [ ^ \n ` ] + ?` / g;
1111const latexBlockReg = / ( \$ { 2 , } ) [ \s \S ] + ?\1/ g;
1212const scriptSetupReg = / \\ < [ \s \S ] + ?> \n ? / g;
13+ const codeSnippetImportReg = / ^ \s * < < < \s * .+ / gm;
14+ const sfcBlockReg = / < ( s c r i p t | s t y l e ) \b [ \s \S ] * ?> ( [ \s \S ] * ?) < \/ \1> / g;
1315const angleBracketReg = / < \S * : \S * > / g;
1416const linkReg = / \[ [ \s \S ] * ?\] \( [ \s \S ] * ?\) / g;
15- const sfcBlockReg = / < ( s c r i p t | s t y l e ) \b [ \s \S ] * ?> ( [ \s \S ] * ?) < \/ \1> / g;
16- const codeSnippetImportReg = / ^ \s * < < < \s * .+ / gm;
1717
1818const plugin : VueLanguagePlugin = ( { vueCompilerOptions } ) => {
1919 return {
@@ -46,11 +46,7 @@ const plugin: VueLanguagePlugin = ({ vueCompilerOptions }) => {
4646 // # \<script setup>
4747 . replace ( scriptSetupReg , match => ' ' . repeat ( match . length ) )
4848 // <<< https://vitepress.dev/guide/markdown#import-code-snippets
49- . replace ( codeSnippetImportReg , match => ' ' . repeat ( match . length ) )
50- // angle bracket: <http://foo.com>
51- . replace ( angleBracketReg , match => ' ' . repeat ( match . length ) )
52- // [foo](http://foo.com)
53- . replace ( linkReg , match => ' ' . repeat ( match . length ) ) ;
49+ . replace ( codeSnippetImportReg , match => ' ' . repeat ( match . length ) ) ;
5450
5551 const codes : Segment [ ] = [ ] ;
5652
@@ -62,6 +58,12 @@ const plugin: VueLanguagePlugin = ({ vueCompilerOptions }) => {
6258 + content . slice ( match . index + matchText . length ) ;
6359 }
6460
61+ content = content
62+ // angle bracket: <http://foo.com>
63+ . replace ( angleBracketReg , match => ' ' . repeat ( match . length ) )
64+ // [foo](http://foo.com)
65+ . replace ( linkReg , match => ' ' . repeat ( match . length ) ) ;
66+
6567 codes . push ( '<template>\n' ) ;
6668 codes . push ( [ content , undefined , 0 ] ) ;
6769 codes . push ( '\n</template>' ) ;
0 commit comments