Add intermediate stage for text markup.

This commit is contained in:
Tom Alexander 2023-10-31 19:57:04 -04:00
parent ae933b491e
commit 0fae417610
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
8 changed files with 97 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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