From ef644f4def7d5cad3fb5307ec5e00fc7b0b025ff Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 13 Jun 2022 18:42:36 +0200 Subject: Add basic html (text) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add all states for html (text) * Fix to link paragraph tokens together * Add note about uncovered bug where linking paragraph tokens together doesn’t work 😅 --- src/tokenizer.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/tokenizer.rs') diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 4c1caa4..8a2f477 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -58,6 +58,9 @@ pub enum TokenType { HtmlFlow, HtmlFlowData, + HtmlText, + HtmlTextData, + ThematicBreak, ThematicBreakSequence, ThematicBreakWhitespace, @@ -420,7 +423,14 @@ impl Tokenizer { b: impl FnOnce(&mut Tokenizer, Code) -> StateFnResult + 'static, done: impl FnOnce(bool) -> Box + 'static, ) -> Box { - self.call_multiple(false, Some(Box::new(a)), Some(Box::new(b)), None, done) + self.call_multiple( + false, + Some(Box::new(a)), + Some(Box::new(b)), + None, + None, + done, + ) } pub fn attempt_3( @@ -435,6 +445,25 @@ impl Tokenizer { Some(Box::new(a)), Some(Box::new(b)), Some(Box::new(c)), + None, + done, + ) + } + + pub fn attempt_4( + &mut self, + a: impl FnOnce(&mut Tokenizer, Code) -> StateFnResult + 'static, + b: impl FnOnce(&mut Tokenizer, Code) -> StateFnResult + 'static, + c: impl FnOnce(&mut Tokenizer, Code) -> StateFnResult + 'static, + d: impl FnOnce(&mut Tokenizer, Code) -> StateFnResult + 'static, + done: impl FnOnce(bool) -> Box + 'static, + ) -> Box { + self.call_multiple( + false, + Some(Box::new(a)), + Some(Box::new(b)), + Some(Box::new(c)), + Some(Box::new(d)), done, ) } @@ -445,6 +474,7 @@ impl Tokenizer { a: Option>, b: Option>, c: Option>, + d: Option>, done: impl FnOnce(bool) -> Box + 'static, ) -> Box { if let Some(head) = a { @@ -453,7 +483,7 @@ impl Tokenizer { done(ok) } else { Box::new(move |tokenizer: &mut Tokenizer, code| { - tokenizer.call_multiple(check, b, c, None, done)(tokenizer, code) + tokenizer.call_multiple(check, b, c, d, None, done)(tokenizer, code) }) } }; -- cgit