Skip to content

Commit ac7235d

Browse files
authored
fix(language-core): ignore frontmatter block in markdown files (#5362)
1 parent 45826c7 commit ac7235d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"pnpm": {
3333
"onlyBuiltDependencies": [
3434
"@tsslint/core",
35+
"@tsslint/eslint",
3536
"@vscode/vsce-sign",
3637
"esbuild",
3738
"keytar",

packages/language-core/lib/plugins/file-md.ts

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { VueLanguagePlugin } from '../types';
55
import { buildMappings } from '../utils/buildMappings';
66
import { parse } from '../utils/parseSfc';
77

8+
const frontmatterReg = /^---[\s\S]*?\n---(?:\r?\n|$)/;
89
const codeblockReg = /(`{3,})[\s\S]+?\1/g;
910
const inlineCodeblockReg = /`[^\n`]+?`/g;
1011
const latexBlockReg = /(\${2,})[\s\S]+?\1/g;
@@ -36,6 +37,8 @@ const plugin: VueLanguagePlugin = ({ vueCompilerOptions }) => {
3637
}
3738

3839
content = content
40+
// frontmatter
41+
.replace(frontmatterReg, match => ' '.repeat(match.length))
3942
// code block
4043
.replace(codeblockReg, (match, quotes) => quotes + ' '.repeat(match.length - quotes.length * 2) + quotes)
4144
// inline code block

0 commit comments

Comments
 (0)