Add element.

This commit is contained in:
Tom Alexander 2023-10-27 15:32:24 -04:00
parent 7b01230234
commit 5b34942b64
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 81 additions and 7 deletions

View File

@ -1,5 +1,22 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IElement;
#[derive(Debug, Serialize)]
#[serde(untagged)]
pub(crate) enum RenderElement {}
impl RenderElement {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
config: &Config,
output_directory: D,
output_file: F,
element: &IElement,
) -> Result<RenderElement, CustomError> {
todo!()
}
}

View File

@ -6,10 +6,14 @@ use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ISection;
use super::RenderElement;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "section")]
pub(crate) struct RenderSection {}
pub(crate) struct RenderSection {
children: Vec<RenderElement>,
}
impl RenderSection {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
@ -18,6 +22,12 @@ impl RenderSection {
output_file: F,
section: &ISection,
) -> Result<RenderSection, CustomError> {
Ok(RenderSection {})
let children = section
.children
.iter()
.map(|obj| RenderElement::new(config, &output_directory, &output_file, obj))
.collect::<Result<Vec<_>, _>>()?;
Ok(RenderSection { children })
}
}

View File

@ -1,2 +1,40 @@
use crate::error::CustomError;
use super::registry::Registry;
#[derive(Debug)]
pub(crate) enum IElement {}
impl IElement {
pub(crate) fn new<'parse>(
registry: &mut Registry<'parse>,
elem: &organic::types::Element<'parse>,
) -> Result<IElement, CustomError> {
match elem {
organic::types::Element::Paragraph(_) => todo!(),
organic::types::Element::PlainList(_) => todo!(),
organic::types::Element::CenterBlock(_) => todo!(),
organic::types::Element::QuoteBlock(_) => todo!(),
organic::types::Element::SpecialBlock(_) => todo!(),
organic::types::Element::DynamicBlock(_) => todo!(),
organic::types::Element::FootnoteDefinition(_) => todo!(),
organic::types::Element::Comment(_) => todo!(),
organic::types::Element::Drawer(_) => todo!(),
organic::types::Element::PropertyDrawer(_) => todo!(),
organic::types::Element::Table(_) => todo!(),
organic::types::Element::VerseBlock(_) => todo!(),
organic::types::Element::CommentBlock(_) => todo!(),
organic::types::Element::ExampleBlock(_) => todo!(),
organic::types::Element::ExportBlock(_) => todo!(),
organic::types::Element::SrcBlock(_) => todo!(),
organic::types::Element::Clock(_) => todo!(),
organic::types::Element::DiarySexp(_) => todo!(),
organic::types::Element::Planning(_) => todo!(),
organic::types::Element::FixedWidthArea(_) => todo!(),
organic::types::Element::HorizontalRule(_) => todo!(),
organic::types::Element::Keyword(_) => todo!(),
organic::types::Element::BabelCall(_) => todo!(),
organic::types::Element::LatexEnvironment(_) => todo!(),
}
}
}

View File

@ -1,15 +1,24 @@
use crate::error::CustomError;
use super::registry::Registry;
use super::IElement;
#[derive(Debug)]
pub(crate) struct ISection {}
pub(crate) struct ISection {
pub(crate) children: Vec<IElement>,
}
impl ISection {
pub(crate) fn new(
registry: &mut Registry<'_>,
section: &organic::types::Section<'_>,
pub(crate) fn new<'parse>(
registry: &mut Registry<'parse>,
section: &organic::types::Section<'parse>,
) -> Result<ISection, CustomError> {
Ok(ISection {})
let children = section
.children
.iter()
.map(|obj| IElement::new(registry, obj))
.collect::<Result<Vec<_>, _>>()?;
Ok(ISection { children })
}
}