Add paragraph.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
use super::IParagraph;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum IElement {}
|
||||
pub(crate) enum IElement {
|
||||
Paragraph(IParagraph),
|
||||
}
|
||||
|
||||
impl IElement {
|
||||
pub(crate) fn new<'parse>(
|
||||
@@ -11,7 +14,9 @@ impl IElement {
|
||||
elem: &organic::types::Element<'parse>,
|
||||
) -> Result<IElement, CustomError> {
|
||||
match elem {
|
||||
organic::types::Element::Paragraph(_) => todo!(),
|
||||
organic::types::Element::Paragraph(inner) => {
|
||||
Ok(IElement::Paragraph(IParagraph::new(registry, inner)?))
|
||||
}
|
||||
organic::types::Element::PlainList(_) => todo!(),
|
||||
organic::types::Element::CenterBlock(_) => todo!(),
|
||||
organic::types::Element::QuoteBlock(_) => todo!(),
|
||||
|
||||
@@ -5,6 +5,7 @@ mod element;
|
||||
mod heading;
|
||||
mod object;
|
||||
mod page;
|
||||
mod paragraph;
|
||||
mod plain_text;
|
||||
mod registry;
|
||||
mod section;
|
||||
@@ -17,6 +18,7 @@ pub(crate) use element::IElement;
|
||||
pub(crate) use heading::IHeading;
|
||||
pub(crate) use object::IObject;
|
||||
pub(crate) use page::BlogPostPage;
|
||||
pub(crate) use paragraph::IParagraph;
|
||||
pub(crate) use plain_text::IPlainText;
|
||||
pub(crate) use section::ISection;
|
||||
pub(crate) use target::ITarget;
|
||||
|
||||
@@ -22,8 +22,8 @@ impl IObject {
|
||||
organic::types::Object::StrikeThrough(_) => todo!(),
|
||||
organic::types::Object::Code(_) => todo!(),
|
||||
organic::types::Object::Verbatim(_) => todo!(),
|
||||
organic::types::Object::PlainText(plain_text) => {
|
||||
Ok(IObject::PlainText(IPlainText::new(registry, plain_text)?))
|
||||
organic::types::Object::PlainText(inner) => {
|
||||
Ok(IObject::PlainText(IPlainText::new(registry, inner)?))
|
||||
}
|
||||
organic::types::Object::RegularLink(_) => todo!(),
|
||||
organic::types::Object::RadioLink(_) => todo!(),
|
||||
@@ -40,8 +40,8 @@ impl IObject {
|
||||
organic::types::Object::InlineBabelCall(_) => todo!(),
|
||||
organic::types::Object::InlineSourceBlock(_) => todo!(),
|
||||
organic::types::Object::LineBreak(_) => todo!(),
|
||||
organic::types::Object::Target(target) => {
|
||||
Ok(IObject::Target(ITarget::new(registry, target)?))
|
||||
organic::types::Object::Target(inner) => {
|
||||
Ok(IObject::Target(ITarget::new(registry, inner)?))
|
||||
}
|
||||
organic::types::Object::StatisticsCookie(_) => todo!(),
|
||||
organic::types::Object::Subscript(_) => todo!(),
|
||||
|
||||
24
src/intermediate/paragraph.rs
Normal file
24
src/intermediate/paragraph.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
use super::IObject;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct IParagraph {
|
||||
pub(crate) children: Vec<IObject>,
|
||||
}
|
||||
|
||||
impl IParagraph {
|
||||
pub(crate) fn new<'parse>(
|
||||
registry: &mut Registry<'parse>,
|
||||
paragraph: &organic::types::Paragraph<'parse>,
|
||||
) -> Result<IParagraph, CustomError> {
|
||||
let children = paragraph
|
||||
.children
|
||||
.iter()
|
||||
.map(|obj| IObject::new(registry, obj))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
Ok(IParagraph { children })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user