Add render stage for text markup.

This commit is contained in:
Tom Alexander 2023-10-31 20:02:04 -04:00
parent 0fae417610
commit 159d8fb72a
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
6 changed files with 150 additions and 18 deletions

View File

@ -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<RenderObject>,
}
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 })
}
);

View File

@ -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(),
})
}
);

View File

@ -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<RenderObject>,
}
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 })
}
);

View File

@ -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<RenderObject>,
}
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 })
}
);

View File

@ -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<RenderObject>,
}
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 })
}
);

View File

@ -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(),
})
}
);