Filling in more of the iter_tokens tree.

This commit is contained in:
Tom Alexander 2023-07-14 20:18:30 -04:00
parent 0e73b83bf3
commit 08e6efe5f5
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -4,6 +4,8 @@ use super::Heading;
use super::Object; use super::Object;
use super::PlainListItem; use super::PlainListItem;
use super::Section; use super::Section;
use super::TableCell;
use super::TableRow;
use crate::parser::DocumentElement; use crate::parser::DocumentElement;
pub enum Token<'r, 's> { pub enum Token<'r, 's> {
@ -13,6 +15,8 @@ pub enum Token<'r, 's> {
Object(&'r Object<'s>), Object(&'r Object<'s>),
Element(&'r Element<'s>), Element(&'r Element<'s>),
PlainListItem(&'r PlainListItem<'s>), PlainListItem(&'r PlainListItem<'s>),
TableRow(&'r TableRow<'s>),
TableCell(&'r TableCell<'s>),
} }
impl<'r, 's> Token<'r, 's> { impl<'r, 's> Token<'r, 's> {
@ -53,26 +57,30 @@ impl<'r, 's> Token<'r, 's> {
Box::new(inner.children.iter().map(Token::PlainListItem)) Box::new(inner.children.iter().map(Token::PlainListItem))
} }
Element::GreaterBlock(inner) => Box::new(inner.children.iter().map(Token::Element)), Element::GreaterBlock(inner) => Box::new(inner.children.iter().map(Token::Element)),
Element::DynamicBlock(_) => todo!(), Element::DynamicBlock(inner) => Box::new(inner.children.iter().map(Token::Element)),
Element::FootnoteDefinition(_) => todo!(), Element::FootnoteDefinition(inner) => {
Element::Comment(_) => todo!(), Box::new(inner.children.iter().map(Token::Element))
Element::Drawer(_) => todo!(), }
Element::PropertyDrawer(_) => todo!(), Element::Comment(_) => Box::new(std::iter::empty()),
Element::Table(_) => todo!(), Element::Drawer(inner) => Box::new(inner.children.iter().map(Token::Element)),
Element::VerseBlock(_) => todo!(), Element::PropertyDrawer(_) => Box::new(std::iter::empty()),
Element::CommentBlock(_) => todo!(), Element::Table(inner) => Box::new(inner.children.iter().map(Token::TableRow)),
Element::ExampleBlock(_) => todo!(), Element::VerseBlock(inner) => Box::new(inner.children.iter().map(Token::Object)),
Element::ExportBlock(_) => todo!(), Element::CommentBlock(_) => Box::new(std::iter::empty()),
Element::SrcBlock(_) => todo!(), Element::ExampleBlock(_) => Box::new(std::iter::empty()),
Element::Clock(_) => todo!(), Element::ExportBlock(_) => Box::new(std::iter::empty()),
Element::DiarySexp(_) => todo!(), Element::SrcBlock(_) => Box::new(std::iter::empty()),
Element::Planning(_) => todo!(), Element::Clock(_) => Box::new(std::iter::empty()),
Element::FixedWidthArea(_) => todo!(), Element::DiarySexp(_) => Box::new(std::iter::empty()),
Element::HorizontalRule(_) => todo!(), Element::Planning(_) => Box::new(std::iter::empty()),
Element::Keyword(_) => todo!(), Element::FixedWidthArea(_) => Box::new(std::iter::empty()),
Element::LatexEnvironment(_) => todo!(), Element::HorizontalRule(_) => Box::new(std::iter::empty()),
Element::Keyword(_) => Box::new(std::iter::empty()),
Element::LatexEnvironment(_) => Box::new(std::iter::empty()),
}, },
Token::PlainListItem(elem) => Box::new(elem.children.iter().map(Token::Element)), Token::PlainListItem(elem) => Box::new(elem.children.iter().map(Token::Element)),
Token::TableRow(elem) => Box::new(elem.children.iter().map(Token::TableCell)),
Token::TableCell(elem) => Box::new(elem.children.iter().map(Token::Object)),
} }
} }
} }