From 42ca801712cdd5642183c9297dca70eddd03e2b0 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Thu, 19 Jan 2023 22:16:01 +0100 Subject: [PATCH] rm from_container_block --- src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 48343a2..bcd3eff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -254,15 +254,6 @@ impl<'s> Container<'s> { _ => todo!(), } } - - fn from_container_block(content: &'s str, c: block::Container) -> Self { - match c { - block::Container::Blockquote => Self::Blockquote, - block::Container::Div => panic!(), - block::Container::Footnote => panic!(), - block::Container::ListItem => todo!(), - } - } } pub struct Parser<'s> { @@ -474,6 +465,7 @@ impl<'s> Parser<'s> { } block::Node::Container(c) => { let container = match c { + block::Container::Blockquote => Container::Blockquote, block::Container::Div { .. } => Container::Div { class: (!ev.span.is_empty()).then(|| content), }, @@ -481,7 +473,7 @@ impl<'s> Parser<'s> { self.footnotes.insert(content, self.tree.take_branch()); continue; } - _ => Container::from_container_block(content, c), + block::Container::ListItem => panic!(), }; Event::Start(container, attributes) } @@ -489,7 +481,15 @@ impl<'s> Parser<'s> { tree::EventKind::Exit(c) => match c { block::Node::Leaf(l) => Event::End(Container::from_leaf_block(content, l)), block::Node::Container(c) => { - Event::End(Container::from_container_block(content, c)) + let container = match c { + block::Container::Blockquote => Container::Blockquote, + block::Container::Div { .. } => Container::Div { + class: (!ev.span.is_empty()).then(|| content), + }, + block::Container::Footnote => panic!(), + block::Container::ListItem => panic!(), + }; + Event::End(container) } }, tree::EventKind::Inline => unreachable!(),