From be95adc1d5938caddf54723546a18578e25e9c5d Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 5 Dec 2024 22:44:43 +0800 Subject: [PATCH] add comment --- packages/markdown/remark/src/frontmatter.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/markdown/remark/src/frontmatter.ts b/packages/markdown/remark/src/frontmatter.ts index d8ed74474e07..94fbec2b3312 100644 --- a/packages/markdown/remark/src/frontmatter.ts +++ b/packages/markdown/remark/src/frontmatter.ts @@ -10,6 +10,9 @@ export function isFrontmatterValid(frontmatter: Record) { return typeof frontmatter === 'object' && frontmatter !== null; } +// Capture frontmatter wrapped with `---`, including any characters and new lines within it. +// Only capture if it exists near the top of the file (whitespaces between the start of file and +// the start of `---` are allowed) const frontmatterRE = /^\s*---([\s\S]*?\n)---/; export function extractFrontmatter(code: string): string | undefined { return frontmatterRE.exec(code)?.[1];