Compare commits

..

No commits in common. "5bbb12327bde2815fc03697231c504df7817cbff" and "4c3bea06d10d968d89acbd358fb3e99f8c980f90" have entirely different histories.

14 changed files with 177 additions and 227 deletions

View File

@ -1,3 +1 @@
<b>{#.children} bold
{>object/}
{/.children}</b>

View File

@ -1 +1 @@
<code>{.source}</code> code

View File

@ -1,3 +1 @@
<i>{#.children} italic
{>object/}
{/.children}</i>

View File

@ -1 +1 @@
{.source} plain_text

View File

@ -1,3 +1 @@
<blockquote>{#.children} quote_block
{>element/}
{/.children}</blockquote>

View File

@ -1,3 +1 @@
<del>{#.children} strike_through
{>object/}
{/.children}</del>

View File

@ -1,3 +1 @@
<u>{#.children} underline
{>object/}
{/.children}</u>

View File

@ -1 +1 @@
<code>{.source}</code> verbatim

View File

@ -9,19 +9,15 @@ use crate::intermediate::IPlainText;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename = "plain_text")] #[serde(rename = "plain_text")]
pub(crate) struct RenderPlainText { pub(crate) struct RenderPlainText {}
source: String,
}
impl RenderPlainText { impl RenderPlainText {
pub(crate) fn new( pub(crate) fn new(
config: &Config, config: &Config,
output_directory: &Path, output_directory: &Path,
output_file: &Path, output_file: &Path,
original: &IPlainText, heading: &IPlainText,
) -> Result<RenderPlainText, CustomError> { ) -> Result<RenderPlainText, CustomError> {
Ok(RenderPlainText { Ok(RenderPlainText {})
source: original.source.clone(),
})
} }
} }

View File

@ -6,14 +6,10 @@ use crate::config::Config;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IQuoteBlock; use crate::intermediate::IQuoteBlock;
use super::RenderElement;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename = "quote_block")] #[serde(rename = "quote_block")]
pub(crate) struct RenderQuoteBlock { pub(crate) struct RenderQuoteBlock {}
children: Vec<RenderElement>,
}
impl RenderQuoteBlock { impl RenderQuoteBlock {
pub(crate) fn new( pub(crate) fn new(
@ -22,19 +18,6 @@ impl RenderQuoteBlock {
output_file: &Path, output_file: &Path,
original: &IQuoteBlock, original: &IQuoteBlock,
) -> Result<RenderQuoteBlock, CustomError> { ) -> Result<RenderQuoteBlock, CustomError> {
let children = { Ok(RenderQuoteBlock {})
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(RenderElement::new(
config,
&output_directory,
&output_file,
obj,
)?);
}
ret
};
Ok(RenderQuoteBlock { children })
} }
} }

View File

@ -25,7 +25,6 @@ use super::ISpecialBlock;
use super::ISrcBlock; use super::ISrcBlock;
use super::ITable; use super::ITable;
use super::IVerseBlock; use super::IVerseBlock;
use futures::future::{BoxFuture, FutureExt};
#[derive(Debug)] #[derive(Debug)]
pub(crate) enum IElement { pub(crate) enum IElement {
@ -56,86 +55,83 @@ pub(crate) enum IElement {
} }
impl IElement { impl IElement {
pub(crate) fn new<'parse, 'b>( pub(crate) async fn new<'parse>(
registry: &'b mut Registry<'parse>, registry: &mut Registry<'parse>,
elem: &'b organic::types::Element<'parse>, elem: &organic::types::Element<'parse>,
) -> BoxFuture<'b, Result<IElement, CustomError>> { ) -> Result<IElement, CustomError> {
async move { match elem {
match elem { organic::types::Element::Paragraph(inner) => {
organic::types::Element::Paragraph(inner) => { Ok(IElement::Paragraph(IParagraph::new(registry, inner).await?))
Ok(IElement::Paragraph(IParagraph::new(registry, inner).await?))
}
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?),
),
organic::types::Element::Comment(inner) => {
Ok(IElement::Comment(IComment::new(registry, inner).await?))
}
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?,
)),
organic::types::Element::Keyword(inner) => {
Ok(IElement::Keyword(IKeyword::new(registry, inner).await?))
}
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?,
)),
} }
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?,
)),
organic::types::Element::Comment(inner) => {
Ok(IElement::Comment(IComment::new(registry, inner).await?))
}
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?,
)),
organic::types::Element::Keyword(inner) => {
Ok(IElement::Keyword(IKeyword::new(registry, inner).await?))
}
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?,
)),
} }
.boxed()
} }
} }

View File

@ -28,7 +28,6 @@ use super::timestamp::ITimestamp;
use super::underline::IUnderline; use super::underline::IUnderline;
use super::verbatim::IVerbatim; use super::verbatim::IVerbatim;
use super::ITarget; use super::ITarget;
use futures::future::{BoxFuture, FutureExt};
#[derive(Debug)] #[derive(Debug)]
pub(crate) enum IObject { pub(crate) enum IObject {
@ -62,95 +61,92 @@ pub(crate) enum IObject {
} }
impl IObject { impl IObject {
pub(crate) fn new<'parse, 'b>( pub(crate) async fn new<'parse>(
registry: &'b mut Registry<'parse>, registry: &mut Registry<'parse>,
obj: &'b organic::types::Object<'parse>, obj: &organic::types::Object<'parse>,
) -> BoxFuture<'b, Result<IObject, CustomError>> { ) -> Result<IObject, CustomError> {
async move { match obj {
match obj { organic::types::Object::Bold(inner) => {
organic::types::Object::Bold(inner) => { Ok(IObject::Bold(IBold::new(registry, inner).await?))
Ok(IObject::Bold(IBold::new(registry, inner).await?)) }
} organic::types::Object::Italic(inner) => {
organic::types::Object::Italic(inner) => { Ok(IObject::Italic(IItalic::new(registry, inner).await?))
Ok(IObject::Italic(IItalic::new(registry, inner).await?)) }
} organic::types::Object::Underline(inner) => {
organic::types::Object::Underline(inner) => { Ok(IObject::Underline(IUnderline::new(registry, inner).await?))
Ok(IObject::Underline(IUnderline::new(registry, inner).await?)) }
} organic::types::Object::StrikeThrough(inner) => Ok(IObject::StrikeThrough(
organic::types::Object::StrikeThrough(inner) => Ok(IObject::StrikeThrough( IStrikeThrough::new(registry, inner).await?,
IStrikeThrough::new(registry, inner).await?, )),
)), organic::types::Object::Code(inner) => {
organic::types::Object::Code(inner) => { Ok(IObject::Code(ICode::new(registry, inner).await?))
Ok(IObject::Code(ICode::new(registry, inner).await?)) }
} organic::types::Object::Verbatim(inner) => {
organic::types::Object::Verbatim(inner) => { Ok(IObject::Verbatim(IVerbatim::new(registry, inner).await?))
Ok(IObject::Verbatim(IVerbatim::new(registry, inner).await?)) }
} organic::types::Object::PlainText(inner) => {
organic::types::Object::PlainText(inner) => { Ok(IObject::PlainText(IPlainText::new(registry, inner).await?))
Ok(IObject::PlainText(IPlainText::new(registry, inner).await?)) }
} organic::types::Object::RegularLink(inner) => Ok(IObject::RegularLink(
organic::types::Object::RegularLink(inner) => Ok(IObject::RegularLink( IRegularLink::new(registry, inner).await?,
IRegularLink::new(registry, inner).await?, )),
)), organic::types::Object::RadioLink(inner) => {
organic::types::Object::RadioLink(inner) => { Ok(IObject::RadioLink(IRadioLink::new(registry, inner).await?))
Ok(IObject::RadioLink(IRadioLink::new(registry, inner).await?)) }
} organic::types::Object::RadioTarget(inner) => Ok(IObject::RadioTarget(
organic::types::Object::RadioTarget(inner) => Ok(IObject::RadioTarget( IRadioTarget::new(registry, inner).await?,
IRadioTarget::new(registry, inner).await?, )),
)), organic::types::Object::PlainLink(inner) => {
organic::types::Object::PlainLink(inner) => { Ok(IObject::PlainLink(IPlainLink::new(registry, inner).await?))
Ok(IObject::PlainLink(IPlainLink::new(registry, inner).await?)) }
} organic::types::Object::AngleLink(inner) => {
organic::types::Object::AngleLink(inner) => { Ok(IObject::AngleLink(IAngleLink::new(registry, inner).await?))
Ok(IObject::AngleLink(IAngleLink::new(registry, inner).await?)) }
} organic::types::Object::OrgMacro(inner) => {
organic::types::Object::OrgMacro(inner) => { Ok(IObject::OrgMacro(IOrgMacro::new(registry, inner).await?))
Ok(IObject::OrgMacro(IOrgMacro::new(registry, inner).await?)) }
} organic::types::Object::Entity(inner) => {
organic::types::Object::Entity(inner) => { Ok(IObject::Entity(IEntity::new(registry, inner).await?))
Ok(IObject::Entity(IEntity::new(registry, inner).await?)) }
} organic::types::Object::LatexFragment(inner) => Ok(IObject::LatexFragment(
organic::types::Object::LatexFragment(inner) => Ok(IObject::LatexFragment( ILatexFragment::new(registry, inner).await?,
ILatexFragment::new(registry, inner).await?, )),
)), organic::types::Object::ExportSnippet(inner) => Ok(IObject::ExportSnippet(
organic::types::Object::ExportSnippet(inner) => Ok(IObject::ExportSnippet( IExportSnippet::new(registry, inner).await?,
IExportSnippet::new(registry, inner).await?, )),
)), organic::types::Object::FootnoteReference(inner) => Ok(IObject::FootnoteReference(
organic::types::Object::FootnoteReference(inner) => Ok(IObject::FootnoteReference( IFootnoteReference::new(registry, inner).await?,
IFootnoteReference::new(registry, inner).await?, )),
)), organic::types::Object::Citation(inner) => {
organic::types::Object::Citation(inner) => { Ok(IObject::Citation(ICitation::new(registry, inner).await?))
Ok(IObject::Citation(ICitation::new(registry, inner).await?)) }
} organic::types::Object::CitationReference(inner) => Ok(IObject::CitationReference(
organic::types::Object::CitationReference(inner) => Ok(IObject::CitationReference( ICitationReference::new(registry, inner).await?,
ICitationReference::new(registry, inner).await?, )),
)), organic::types::Object::InlineBabelCall(inner) => Ok(IObject::InlineBabelCall(
organic::types::Object::InlineBabelCall(inner) => Ok(IObject::InlineBabelCall( IInlineBabelCall::new(registry, inner).await?,
IInlineBabelCall::new(registry, inner).await?, )),
)), organic::types::Object::InlineSourceBlock(inner) => Ok(IObject::InlineSourceBlock(
organic::types::Object::InlineSourceBlock(inner) => Ok(IObject::InlineSourceBlock( IInlineSourceBlock::new(registry, inner).await?,
IInlineSourceBlock::new(registry, inner).await?, )),
)), organic::types::Object::LineBreak(inner) => {
organic::types::Object::LineBreak(inner) => { Ok(IObject::LineBreak(ILineBreak::new(registry, inner).await?))
Ok(IObject::LineBreak(ILineBreak::new(registry, inner).await?)) }
} organic::types::Object::Target(inner) => {
organic::types::Object::Target(inner) => { Ok(IObject::Target(ITarget::new(registry, inner).await?))
Ok(IObject::Target(ITarget::new(registry, inner).await?)) }
} organic::types::Object::StatisticsCookie(inner) => Ok(IObject::StatisticsCookie(
organic::types::Object::StatisticsCookie(inner) => Ok(IObject::StatisticsCookie( IStatisticsCookie::new(registry, inner).await?,
IStatisticsCookie::new(registry, inner).await?, )),
)), organic::types::Object::Subscript(inner) => {
organic::types::Object::Subscript(inner) => { Ok(IObject::Subscript(ISubscript::new(registry, inner).await?))
Ok(IObject::Subscript(ISubscript::new(registry, inner).await?)) }
} organic::types::Object::Superscript(inner) => Ok(IObject::Superscript(
organic::types::Object::Superscript(inner) => Ok(IObject::Superscript( ISuperscript::new(registry, inner).await?,
ISuperscript::new(registry, inner).await?, )),
)), organic::types::Object::Timestamp(inner) => {
organic::types::Object::Timestamp(inner) => { Ok(IObject::Timestamp(ITimestamp::new(registry, inner).await?))
Ok(IObject::Timestamp(ITimestamp::new(registry, inner).await?))
}
} }
} }
.boxed()
} }
} }

View File

@ -5,7 +5,7 @@ use super::registry::Registry;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct IPlainText { pub(crate) struct IPlainText {
pub(crate) source: String, source: String,
} }
impl IPlainText { impl IPlainText {

View File

@ -1,26 +1,15 @@
use crate::error::CustomError; use crate::error::CustomError;
use super::registry::Registry; use super::registry::Registry;
use super::IElement;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct IQuoteBlock { pub(crate) struct IQuoteBlock {}
pub(crate) children: Vec<IElement>,
}
impl IQuoteBlock { impl IQuoteBlock {
pub(crate) async fn new<'parse>( pub(crate) async fn new<'parse>(
registry: &mut Registry<'parse>, registry: &mut Registry<'parse>,
original: &organic::types::QuoteBlock<'parse>, original: &organic::types::QuoteBlock<'parse>,
) -> Result<IQuoteBlock, CustomError> { ) -> Result<IQuoteBlock, CustomError> {
let children = { Ok(IQuoteBlock {})
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(IElement::new(registry, obj).await?);
}
ret
};
Ok(IQuoteBlock { children })
} }
} }