From 6ee90b34c87354baf8e03d5469a92cf5dd17a82b Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 16 Aug 2022 16:49:29 +0200 Subject: Add support for frontmatter --- src/construct/document.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/construct/document.rs') diff --git a/src/construct/document.rs b/src/construct/document.rs index 0cda368..2cc170d 100644 --- a/src/construct/document.rs +++ b/src/construct/document.rs @@ -58,13 +58,29 @@ pub fn start(tokenizer: &mut Tokenizer) -> State { ))); tokenizer.attempt( - State::Next(StateName::DocumentContainerExistingBefore), - State::Next(StateName::DocumentContainerExistingBefore), + State::Next(StateName::DocumentBeforeFrontmatter), + State::Next(StateName::DocumentBeforeFrontmatter), ); State::Retry(StateName::BomStart) } +/// At optional frontmatter. +/// +/// ```markdown +/// > | --- +/// ^ +/// | title: Venus +/// | --- +/// ``` +pub fn before_frontmatter(tokenizer: &mut Tokenizer) -> State { + tokenizer.attempt( + State::Next(StateName::DocumentContainerNewBefore), + State::Next(StateName::DocumentContainerNewBefore), + ); + State::Retry(StateName::FrontmatterStart) +} + /// At optional existing containers. // /// ```markdown -- cgit