File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import matter = require( 'gray-matter' ) ;
21import type {
32 Parser ,
43 ParserOptions ,
@@ -16,12 +15,13 @@ import { options as pugOptions } from './options';
1615import { convergeOptions } from './options/converge' ;
1716import type { PugPrinterOptions } from './printer' ;
1817import { PugPrinter } from './printer' ;
18+ import parse from './utils/frontmatter/parse' ;
1919
2020/** Ast path stack entry. */
2121interface 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 (
You can’t perform that action at this time.
0 commit comments