Skip to content

Commit 43423b1

Browse files
committed
parse frontmatter using prettier's code
1 parent d1a65c7 commit 43423b1

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import matter = require('gray-matter');
21
import type {
32
Parser,
43
ParserOptions,
@@ -16,12 +15,13 @@ import { options as pugOptions } from './options';
1615
import { convergeOptions } from './options/converge';
1716
import type { PugPrinterOptions } from './printer';
1817
import { PugPrinter } from './printer';
18+
import parse from './utils/frontmatter/parse';
1919

2020
/** Ast path stack entry. */
2121
interface AstPathStackEntry {
2222
content: string;
2323
tokens: Token[];
24-
frontmatter: matter.GrayMatterFile<string>;
24+
frontmatter: Frontmatter<string>;
2525
}
2626

2727
/** The plugin object that is picked up by prettier. */
@@ -44,8 +44,10 @@ export const plugin: Plugin<AstPathStackEntry> = {
4444
pug: {
4545
parse(text, options) {
4646
logger.debug('[parsers:pug:parse]:', { text });
47-
const frontmatter = matter(text);
48-
text = frontmatter.content;
47+
48+
const parts = parse(text);
49+
const frontmatter = parts.frontMatter;
50+
text = parts.content;
4951

5052
let trimmedAndAlignedContent: string = text.replace(/^\s*\n/, '');
5153
const contentIndentation: RegExpExecArray | null = /^\s*/.exec(

0 commit comments

Comments
 (0)