From 60ea2fd3a09f10fa28bf48575736b47afebf3221 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 16 Jun 2022 19:04:16 +0200 Subject: Add heading (setext) --- src/content/content.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/content/content.rs') diff --git a/src/content/content.rs b/src/content/content.rs index 4660fbe..4ca69ee 100644 --- a/src/content/content.rs +++ b/src/content/content.rs @@ -27,7 +27,7 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { unreachable!("expected non-eol/eof"); } - _ => paragraph_initial(tokenizer, code) + _ => after_definitions(tokenizer, code) // To do: definition. // _ => tokenizer.attempt(definition, |ok| { // Box::new(if ok { @@ -39,6 +39,21 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { } } +/// Before a paragraph. +/// +/// ```markdown +/// |asd +/// ``` +fn after_definitions(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { + match code { + Code::None => (State::Ok, None), + Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { + unreachable!("to do: handle eol after definition"); + } + _ => paragraph_initial(tokenizer, code), + } +} + /// Before a paragraph. /// /// ```markdown @@ -46,8 +61,9 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { /// ``` fn paragraph_initial(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { match code { - Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { - unreachable!("expected non-eol/eof"); + Code::None => (State::Ok, None), + Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { + unreachable!("to do: handle eol after definition"); } _ => { tokenizer.enter(TokenType::Paragraph); -- cgit