Skip to content

Commit

Permalink
fix(languare-core): ignore nested codeblocks in markdown file (#3839)
Browse files Browse the repository at this point in the history
  • Loading branch information
so1ve authored Jan 18, 2024
1 parent 70e39ff commit dcc5be2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/language-core/src/plugins/file-md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SFCBlock } from '@vue/compiler-sfc';
import { VueLanguagePlugin } from '../types';
import { parse } from '../utils/parseSfc';

const codeblockReg = /```[\s\S]+?```/g;
const codeblockReg = /(`{3,})[\s\S]+?\1/g;
const inlineCodeblockReg = /`[^\n`]+?`/g;
const scriptSetupReg = /\\\<[\s\S]+?\>\n?/g;
const sfcBlockReg = /\<(script|style)\b[\s\S]*?\>([\s\S]*?)\<\/\1\>/g;
Expand All @@ -23,7 +23,7 @@ const plugin: VueLanguagePlugin = () => {

content = content
// code block
.replace(codeblockReg, match => '```' + ' '.repeat(match.length - 6) + '```')
.replace(codeblockReg, (match, quotes) => quotes + ' '.repeat(match.length - quotes.length * 2) + quotes)
// inline code block
.replace(inlineCodeblockReg, match => `\`${' '.repeat(match.length - 2)}\``)
// # \<script setup>
Expand Down

0 comments on commit dcc5be2

Please sign in to comment.