2023-10-27 19:32:24 +00:00
|
|
|
use crate::error::CustomError;
|
|
|
|
|
2023-10-27 20:13:23 +00:00
|
|
|
use super::comment::IComment;
|
2023-10-27 20:09:44 +00:00
|
|
|
use super::keyword::IKeyword;
|
2023-10-27 19:32:24 +00:00
|
|
|
use super::registry::Registry;
|
2023-10-27 21:08:58 +00:00
|
|
|
use super::IBabelCall;
|
|
|
|
use super::ICenterBlock;
|
|
|
|
use super::IClock;
|
|
|
|
use super::ICommentBlock;
|
|
|
|
use super::IDiarySexp;
|
|
|
|
use super::IDrawer;
|
|
|
|
use super::IDynamicBlock;
|
|
|
|
use super::IExampleBlock;
|
|
|
|
use super::IExportBlock;
|
|
|
|
use super::IFixedWidthArea;
|
|
|
|
use super::IFootnoteDefinition;
|
|
|
|
use super::IHorizontalRule;
|
|
|
|
use super::ILatexEnvironment;
|
2023-10-27 19:46:16 +00:00
|
|
|
use super::IParagraph;
|
2023-10-27 21:08:58 +00:00
|
|
|
use super::IPlainList;
|
|
|
|
use super::IPlanning;
|
|
|
|
use super::IPropertyDrawer;
|
|
|
|
use super::IQuoteBlock;
|
|
|
|
use super::ISpecialBlock;
|
|
|
|
use super::ISrcBlock;
|
|
|
|
use super::ITable;
|
|
|
|
use super::IVerseBlock;
|
2023-10-27 19:32:24 +00:00
|
|
|
|
2023-10-27 17:05:34 +00:00
|
|
|
#[derive(Debug)]
|
2023-10-27 19:46:16 +00:00
|
|
|
pub(crate) enum IElement {
|
|
|
|
Paragraph(IParagraph),
|
2023-10-27 21:08:58 +00:00
|
|
|
PlainList(IPlainList),
|
|
|
|
CenterBlock(ICenterBlock),
|
|
|
|
QuoteBlock(IQuoteBlock),
|
|
|
|
SpecialBlock(ISpecialBlock),
|
|
|
|
DynamicBlock(IDynamicBlock),
|
|
|
|
FootnoteDefinition(IFootnoteDefinition),
|
2023-10-27 20:13:23 +00:00
|
|
|
Comment(IComment),
|
2023-10-27 21:08:58 +00:00
|
|
|
Drawer(IDrawer),
|
|
|
|
PropertyDrawer(IPropertyDrawer),
|
|
|
|
Table(ITable),
|
|
|
|
VerseBlock(IVerseBlock),
|
|
|
|
CommentBlock(ICommentBlock),
|
|
|
|
ExampleBlock(IExampleBlock),
|
|
|
|
ExportBlock(IExportBlock),
|
|
|
|
SrcBlock(ISrcBlock),
|
|
|
|
Clock(IClock),
|
|
|
|
DiarySexp(IDiarySexp),
|
|
|
|
Planning(IPlanning),
|
|
|
|
FixedWidthArea(IFixedWidthArea),
|
|
|
|
HorizontalRule(IHorizontalRule),
|
|
|
|
Keyword(IKeyword),
|
|
|
|
BabelCall(IBabelCall),
|
|
|
|
LatexEnvironment(ILatexEnvironment),
|
2023-10-27 19:46:16 +00:00
|
|
|
}
|
2023-10-27 19:32:24 +00:00
|
|
|
|
|
|
|
impl IElement {
|
2023-10-27 19:55:19 +00:00
|
|
|
pub(crate) async fn new<'parse>(
|
2023-10-27 19:32:24 +00:00
|
|
|
registry: &mut Registry<'parse>,
|
|
|
|
elem: &organic::types::Element<'parse>,
|
|
|
|
) -> Result<IElement, CustomError> {
|
|
|
|
match elem {
|
2023-10-27 19:46:16 +00:00
|
|
|
organic::types::Element::Paragraph(inner) => {
|
2023-10-27 19:55:19 +00:00
|
|
|
Ok(IElement::Paragraph(IParagraph::new(registry, inner).await?))
|
2023-10-27 19:46:16 +00:00
|
|
|
}
|
2023-10-27 21:08:58 +00:00
|
|
|
organic::types::Element::PlainList(inner) => {
|
|
|
|
Ok(IElement::PlainList(IPlainList::new(registry, inner).await?))
|
|
|
|
}
|
|
|
|
organic::types::Element::CenterBlock(inner) => Ok(IElement::CenterBlock(
|
|
|
|
ICenterBlock::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::QuoteBlock(inner) => Ok(IElement::QuoteBlock(
|
|
|
|
IQuoteBlock::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::SpecialBlock(inner) => Ok(IElement::SpecialBlock(
|
|
|
|
ISpecialBlock::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::DynamicBlock(inner) => Ok(IElement::DynamicBlock(
|
|
|
|
IDynamicBlock::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::FootnoteDefinition(inner) => Ok(IElement::FootnoteDefinition(
|
|
|
|
IFootnoteDefinition::new(registry, inner).await?,
|
|
|
|
)),
|
2023-10-27 20:13:23 +00:00
|
|
|
organic::types::Element::Comment(inner) => {
|
|
|
|
Ok(IElement::Comment(IComment::new(registry, inner).await?))
|
|
|
|
}
|
2023-10-27 21:08:58 +00:00
|
|
|
organic::types::Element::Drawer(inner) => {
|
|
|
|
Ok(IElement::Drawer(IDrawer::new(registry, inner).await?))
|
|
|
|
}
|
|
|
|
organic::types::Element::PropertyDrawer(inner) => Ok(IElement::PropertyDrawer(
|
|
|
|
IPropertyDrawer::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::Table(inner) => {
|
|
|
|
Ok(IElement::Table(ITable::new(registry, inner).await?))
|
|
|
|
}
|
|
|
|
organic::types::Element::VerseBlock(inner) => Ok(IElement::VerseBlock(
|
|
|
|
IVerseBlock::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::CommentBlock(inner) => Ok(IElement::CommentBlock(
|
|
|
|
ICommentBlock::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::ExampleBlock(inner) => Ok(IElement::ExampleBlock(
|
|
|
|
IExampleBlock::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::ExportBlock(inner) => Ok(IElement::ExportBlock(
|
|
|
|
IExportBlock::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::SrcBlock(inner) => {
|
|
|
|
Ok(IElement::SrcBlock(ISrcBlock::new(registry, inner).await?))
|
|
|
|
}
|
|
|
|
organic::types::Element::Clock(inner) => {
|
|
|
|
Ok(IElement::Clock(IClock::new(registry, inner).await?))
|
|
|
|
}
|
|
|
|
organic::types::Element::DiarySexp(inner) => {
|
|
|
|
Ok(IElement::DiarySexp(IDiarySexp::new(registry, inner).await?))
|
|
|
|
}
|
|
|
|
organic::types::Element::Planning(inner) => {
|
|
|
|
Ok(IElement::Planning(IPlanning::new(registry, inner).await?))
|
|
|
|
}
|
|
|
|
organic::types::Element::FixedWidthArea(inner) => Ok(IElement::FixedWidthArea(
|
|
|
|
IFixedWidthArea::new(registry, inner).await?,
|
|
|
|
)),
|
|
|
|
organic::types::Element::HorizontalRule(inner) => Ok(IElement::HorizontalRule(
|
|
|
|
IHorizontalRule::new(registry, inner).await?,
|
|
|
|
)),
|
2023-10-27 20:09:44 +00:00
|
|
|
organic::types::Element::Keyword(inner) => {
|
|
|
|
Ok(IElement::Keyword(IKeyword::new(registry, inner).await?))
|
|
|
|
}
|
2023-10-27 21:08:58 +00:00
|
|
|
organic::types::Element::BabelCall(inner) => {
|
|
|
|
Ok(IElement::BabelCall(IBabelCall::new(registry, inner).await?))
|
|
|
|
}
|
|
|
|
organic::types::Element::LatexEnvironment(inner) => Ok(IElement::LatexEnvironment(
|
|
|
|
ILatexEnvironment::new(registry, inner).await?,
|
|
|
|
)),
|
2023-10-27 19:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|