Add paragraph.
This commit is contained in:
@@ -6,9 +6,13 @@ use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IElement;
|
||||
|
||||
use super::paragraph::RenderParagraph;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum RenderElement {}
|
||||
pub(crate) enum RenderElement {
|
||||
Paragraph(RenderParagraph),
|
||||
}
|
||||
|
||||
impl RenderElement {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
@@ -17,6 +21,13 @@ impl RenderElement {
|
||||
output_file: F,
|
||||
element: &IElement,
|
||||
) -> Result<RenderElement, CustomError> {
|
||||
todo!()
|
||||
match element {
|
||||
IElement::Paragraph(inner) => Ok(RenderElement::Paragraph(RenderParagraph::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ mod element;
|
||||
mod global_settings;
|
||||
mod heading;
|
||||
mod object;
|
||||
mod paragraph;
|
||||
mod plain_text;
|
||||
mod section;
|
||||
mod target;
|
||||
|
||||
32
src/context/paragraph.rs
Normal file
32
src/context/paragraph.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IParagraph;
|
||||
|
||||
use super::RenderObject;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "heading")]
|
||||
pub(crate) struct RenderParagraph {
|
||||
children: Vec<RenderObject>,
|
||||
}
|
||||
|
||||
impl RenderParagraph {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
paragraph: &IParagraph,
|
||||
) -> Result<RenderParagraph, CustomError> {
|
||||
let children = paragraph
|
||||
.children
|
||||
.iter()
|
||||
.map(|obj| RenderObject::new(config, &output_directory, &output_file, obj))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(RenderParagraph { children })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user