12 lines
632 B
TypeScript
12 lines
632 B
TypeScript
// Match Jekyll-style front matter blocks (https://jekyllrb.com/docs/front-matter/).
|
|
// Based on regex used by Jekyll: https://github.com/jekyll/jekyll/blob/6dd3cc21c40b98054851846425af06c64f9fb466/lib/jekyll/document.rb#L10
|
|
// Note that JS doesn't support the "\A" anchor, which means we can't use
|
|
// multiline mode.
|
|
// Relevant YAML spec: https://yaml.org/spec/1.2.2/#914-explicit-documents
|
|
export const frontMatterRegex = /^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s;
|
|
|
|
export const directiveRegex =
|
|
/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi;
|
|
|
|
export const anyCommentRegex = /\s*%%.*\n/gm;
|