diff --git a/default_environment/templates/html/code.dust b/default_environment/templates/html/code.dust index d8ccfe4..07d701a 100644 --- a/default_environment/templates/html/code.dust +++ b/default_environment/templates/html/code.dust @@ -1 +1 @@ -{.source} +{.contents} diff --git a/default_environment/templates/html/verbatim.dust b/default_environment/templates/html/verbatim.dust index d8ccfe4..07d701a 100644 --- a/default_environment/templates/html/verbatim.dust +++ b/default_environment/templates/html/verbatim.dust @@ -1 +1 @@ -{.source} +{.contents} diff --git a/src/context/bold.rs b/src/context/bold.rs index 4fdb56e..87c6fb0 100644 --- a/src/context/bold.rs +++ b/src/context/bold.rs @@ -6,11 +6,37 @@ use crate::config::Config; use crate::error::CustomError; use crate::intermediate::IBold; -use super::macros::rnoop; +use super::macros::render; +use super::RenderObject; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "bold")] -pub(crate) struct RenderBold {} +pub(crate) struct RenderBold { + children: Vec, +} -rnoop!(RenderBold, IBold); +render!( + RenderBold, + IBold, + original, + config, + output_directory, + output_file, + { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(RenderObject::new( + config, + output_directory, + output_file, + obj, + )?); + } + ret + }; + + Ok(RenderBold { children }) + } +); diff --git a/src/context/code.rs b/src/context/code.rs index bdad7e2..e03032d 100644 --- a/src/context/code.rs +++ b/src/context/code.rs @@ -6,11 +6,25 @@ use crate::config::Config; use crate::error::CustomError; use crate::intermediate::ICode; -use super::macros::rnoop; +use super::macros::render; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "code")] -pub(crate) struct RenderCode {} +pub(crate) struct RenderCode { + contents: String, +} -rnoop!(RenderCode, ICode); +render!( + RenderCode, + ICode, + original, + config, + output_directory, + output_file, + { + Ok(RenderCode { + contents: original.contents.clone(), + }) + } +); diff --git a/src/context/italic.rs b/src/context/italic.rs index b29320e..d5240b4 100644 --- a/src/context/italic.rs +++ b/src/context/italic.rs @@ -6,11 +6,37 @@ use crate::config::Config; use crate::error::CustomError; use crate::intermediate::IItalic; -use super::macros::rnoop; +use super::macros::render; +use super::RenderObject; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "italic")] -pub(crate) struct RenderItalic {} +pub(crate) struct RenderItalic { + children: Vec, +} -rnoop!(RenderItalic, IItalic); +render!( + RenderItalic, + IItalic, + original, + config, + output_directory, + output_file, + { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(RenderObject::new( + config, + output_directory, + output_file, + obj, + )?); + } + ret + }; + + Ok(RenderItalic { children }) + } +); diff --git a/src/context/strike_through.rs b/src/context/strike_through.rs index be6f960..c84fa37 100644 --- a/src/context/strike_through.rs +++ b/src/context/strike_through.rs @@ -6,11 +6,37 @@ use crate::config::Config; use crate::error::CustomError; use crate::intermediate::IStrikeThrough; -use super::macros::rnoop; +use super::macros::render; +use super::RenderObject; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "strike_through")] -pub(crate) struct RenderStrikeThrough {} +pub(crate) struct RenderStrikeThrough { + children: Vec, +} -rnoop!(RenderStrikeThrough, IStrikeThrough); +render!( + RenderStrikeThrough, + IStrikeThrough, + original, + config, + output_directory, + output_file, + { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(RenderObject::new( + config, + output_directory, + output_file, + obj, + )?); + } + ret + }; + + Ok(RenderStrikeThrough { children }) + } +); diff --git a/src/context/underline.rs b/src/context/underline.rs index cfc1aa6..41cb21c 100644 --- a/src/context/underline.rs +++ b/src/context/underline.rs @@ -6,11 +6,37 @@ use crate::config::Config; use crate::error::CustomError; use crate::intermediate::IUnderline; -use super::macros::rnoop; +use super::macros::render; +use super::RenderObject; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "underline")] -pub(crate) struct RenderUnderline {} +pub(crate) struct RenderUnderline { + children: Vec, +} -rnoop!(RenderUnderline, IUnderline); +render!( + RenderUnderline, + IUnderline, + original, + config, + output_directory, + output_file, + { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(RenderObject::new( + config, + output_directory, + output_file, + obj, + )?); + } + ret + }; + + Ok(RenderUnderline { children }) + } +); diff --git a/src/context/verbatim.rs b/src/context/verbatim.rs index 2456d0c..941317f 100644 --- a/src/context/verbatim.rs +++ b/src/context/verbatim.rs @@ -6,11 +6,25 @@ use crate::config::Config; use crate::error::CustomError; use crate::intermediate::IVerbatim; -use super::macros::rnoop; +use super::macros::render; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "verbatim")] -pub(crate) struct RenderVerbatim {} +pub(crate) struct RenderVerbatim { + contents: String, +} -rnoop!(RenderVerbatim, IVerbatim); +render!( + RenderVerbatim, + IVerbatim, + original, + config, + output_directory, + output_file, + { + Ok(RenderVerbatim { + contents: original.contents.clone(), + }) + } +); diff --git a/src/intermediate/bold.rs b/src/intermediate/bold.rs index 6c4554b..dbca21d 100644 --- a/src/intermediate/bold.rs +++ b/src/intermediate/bold.rs @@ -1,5 +1,21 @@ -use super::macros::inoop; +use super::macros::intermediate; +use super::IObject; use crate::error::CustomError; -inoop!(IBold, Bold); +#[derive(Debug, Clone)] +pub(crate) struct IBold { + pub(crate) children: Vec, +} + +intermediate!(IBold, Bold, original, registry, { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(IObject::new(registry.clone(), obj).await?); + } + ret + }; + + Ok(IBold { children }) +}); diff --git a/src/intermediate/code.rs b/src/intermediate/code.rs index b077f18..b121666 100644 --- a/src/intermediate/code.rs +++ b/src/intermediate/code.rs @@ -1,5 +1,15 @@ -use super::macros::inoop; +use super::macros::intermediate; use crate::error::CustomError; -inoop!(ICode, Code); +#[derive(Debug, Clone)] +pub(crate) struct ICode { + pub(crate) contents: String, +} + +intermediate!(ICode, Code, original, _registry, { + Ok(ICode { + // TODO: Should this coalesce whitespace like PlainText? + contents: original.contents.to_owned(), + }) +}); diff --git a/src/intermediate/italic.rs b/src/intermediate/italic.rs index fed41bd..29d3fb3 100644 --- a/src/intermediate/italic.rs +++ b/src/intermediate/italic.rs @@ -1,5 +1,21 @@ -use super::macros::inoop; +use super::macros::intermediate; +use super::IObject; use crate::error::CustomError; -inoop!(IItalic, Italic); +#[derive(Debug, Clone)] +pub(crate) struct IItalic { + pub(crate) children: Vec, +} + +intermediate!(IItalic, Italic, original, registry, { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(IObject::new(registry.clone(), obj).await?); + } + ret + }; + + Ok(IItalic { children }) +}); diff --git a/src/intermediate/strike_through.rs b/src/intermediate/strike_through.rs index f924fa0..430670b 100644 --- a/src/intermediate/strike_through.rs +++ b/src/intermediate/strike_through.rs @@ -1,5 +1,21 @@ -use super::macros::inoop; +use super::macros::intermediate; +use super::IObject; use crate::error::CustomError; -inoop!(IStrikeThrough, StrikeThrough); +#[derive(Debug, Clone)] +pub(crate) struct IStrikeThrough { + pub(crate) children: Vec, +} + +intermediate!(IStrikeThrough, StrikeThrough, original, registry, { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(IObject::new(registry.clone(), obj).await?); + } + ret + }; + + Ok(IStrikeThrough { children }) +}); diff --git a/src/intermediate/underline.rs b/src/intermediate/underline.rs index 9e2f569..2f35db3 100644 --- a/src/intermediate/underline.rs +++ b/src/intermediate/underline.rs @@ -1,6 +1,21 @@ +use super::macros::intermediate; +use super::IObject; + use crate::error::CustomError; -use super::macros::inoop; +#[derive(Debug, Clone)] +pub(crate) struct IUnderline { + pub(crate) children: Vec, +} +intermediate!(IUnderline, Underline, original, registry, { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(IObject::new(registry.clone(), obj).await?); + } + ret + }; -inoop!(IUnderline, Underline); + Ok(IUnderline { children }) +}); diff --git a/src/intermediate/verbatim.rs b/src/intermediate/verbatim.rs index 8e1e05e..cceb972 100644 --- a/src/intermediate/verbatim.rs +++ b/src/intermediate/verbatim.rs @@ -1,6 +1,15 @@ +use super::macros::intermediate; + use crate::error::CustomError; -use super::macros::inoop; +#[derive(Debug, Clone)] +pub(crate) struct IVerbatim { + pub(crate) contents: String, +} - -inoop!(IVerbatim, Verbatim); +intermediate!(IVerbatim, Verbatim, original, _registry, { + Ok(IVerbatim { + // TODO: Should this coalesce whitespace like PlainText? + contents: original.contents.to_owned(), + }) +});