Standardize the construction of intermediate BlogPostPage.
This commit is contained in:
parent
261fe8a1a2
commit
4bb1f9983a
@ -7,6 +7,7 @@ use tokio::task::JoinHandle;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::page::BlogPostPageInput;
|
||||
use crate::intermediate::registry::Registry;
|
||||
|
||||
use super::BlogPostPage;
|
||||
@ -63,8 +64,11 @@ impl BlogPost {
|
||||
let registry = Arc::new(Mutex::new(registry));
|
||||
let relative_to_post_dir_path = real_path.strip_prefix(post_dir)?;
|
||||
ret.push(
|
||||
BlogPostPage::new(relative_to_post_dir_path, registry, parsed_document)
|
||||
.await?,
|
||||
BlogPostPage::new(
|
||||
registry,
|
||||
BlogPostPageInput::new(relative_to_post_dir_path, parsed_document),
|
||||
)
|
||||
.await?,
|
||||
);
|
||||
}
|
||||
ret
|
||||
|
@ -8,14 +8,20 @@ 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
|
||||
};
|
||||
intermediate!(
|
||||
IBold,
|
||||
&'orig organic::types::Bold<'parse>,
|
||||
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 })
|
||||
});
|
||||
Ok(IBold { children })
|
||||
}
|
||||
);
|
||||
|
@ -7,9 +7,15 @@ 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(),
|
||||
})
|
||||
});
|
||||
intermediate!(
|
||||
ICode,
|
||||
&'orig organic::types::Code<'parse>,
|
||||
original,
|
||||
_registry,
|
||||
{
|
||||
Ok(ICode {
|
||||
// TODO: Should this coalesce whitespace like PlainText?
|
||||
contents: original.contents.to_owned(),
|
||||
})
|
||||
}
|
||||
);
|
||||
|
@ -7,8 +7,14 @@ pub(crate) struct IEntity {
|
||||
pub(crate) html: String,
|
||||
}
|
||||
|
||||
intermediate!(IEntity, Entity, original, _registry, {
|
||||
Ok(IEntity {
|
||||
html: original.html.to_owned(),
|
||||
})
|
||||
});
|
||||
intermediate!(
|
||||
IEntity,
|
||||
&'orig organic::types::Entity<'parse>,
|
||||
original,
|
||||
_registry,
|
||||
{
|
||||
Ok(IEntity {
|
||||
html: original.html.to_owned(),
|
||||
})
|
||||
}
|
||||
);
|
||||
|
@ -10,7 +10,7 @@ pub(crate) struct IFootnoteDefinition {}
|
||||
|
||||
intermediate!(
|
||||
IFootnoteDefinition,
|
||||
FootnoteDefinition,
|
||||
&'orig organic::types::FootnoteDefinition<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
|
@ -9,14 +9,20 @@ pub(crate) struct IFootnoteReference {
|
||||
duplicate_offset: usize,
|
||||
}
|
||||
|
||||
intermediate!(IFootnoteReference, FootnoteReference, original, registry, {
|
||||
let (footnote_id, reference_count) =
|
||||
get_footnote_reference_id(registry, original.label, &original.definition).await?;
|
||||
Ok(IFootnoteReference {
|
||||
footnote_id,
|
||||
duplicate_offset: reference_count,
|
||||
})
|
||||
});
|
||||
intermediate!(
|
||||
IFootnoteReference,
|
||||
&'orig organic::types::FootnoteReference<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let (footnote_id, reference_count) =
|
||||
get_footnote_reference_id(registry, original.label, &original.definition).await?;
|
||||
Ok(IFootnoteReference {
|
||||
footnote_id,
|
||||
duplicate_offset: reference_count,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
impl IFootnoteReference {
|
||||
pub(crate) fn get_display_label(&self) -> String {
|
||||
|
@ -11,24 +11,30 @@ pub(crate) struct IHeading {
|
||||
pub(crate) children: Vec<IDocumentElement>,
|
||||
}
|
||||
|
||||
intermediate!(IHeading, Heading, original, registry, {
|
||||
let title = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.title.iter() {
|
||||
ret.push(IObject::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IDocumentElement::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
Ok(IHeading {
|
||||
title,
|
||||
level: original.level,
|
||||
children,
|
||||
})
|
||||
});
|
||||
intermediate!(
|
||||
IHeading,
|
||||
&'orig organic::types::Heading<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let title = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.title.iter() {
|
||||
ret.push(IObject::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IDocumentElement::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
Ok(IHeading {
|
||||
title,
|
||||
level: original.level,
|
||||
children,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
@ -7,8 +7,14 @@ pub(crate) struct IInlineSourceBlock {
|
||||
pub(crate) value: String,
|
||||
}
|
||||
|
||||
intermediate!(IInlineSourceBlock, InlineSourceBlock, original, _registry, {
|
||||
Ok(IInlineSourceBlock {
|
||||
value: original.value.to_owned(),
|
||||
})
|
||||
});
|
||||
intermediate!(
|
||||
IInlineSourceBlock,
|
||||
&'orig organic::types::InlineSourceBlock<'parse>,
|
||||
original,
|
||||
_registry,
|
||||
{
|
||||
Ok(IInlineSourceBlock {
|
||||
value: original.value.to_owned(),
|
||||
})
|
||||
}
|
||||
);
|
||||
|
@ -8,14 +8,20 @@ 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
|
||||
};
|
||||
intermediate!(
|
||||
IItalic,
|
||||
&'orig organic::types::Italic<'parse>,
|
||||
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 })
|
||||
});
|
||||
Ok(IItalic { children })
|
||||
}
|
||||
);
|
||||
|
@ -7,13 +7,19 @@ pub(crate) struct ILatexFragment {
|
||||
pub(crate) value: String,
|
||||
}
|
||||
|
||||
intermediate!(ILatexFragment, LatexFragment, original, _registry, {
|
||||
let value: String = if original.value.starts_with("$$") && original.value.ends_with("$$") {
|
||||
format!("\\[{}\\]", &original.value[2..(original.value.len() - 2)])
|
||||
} else if original.value.starts_with("$") && original.value.ends_with("$") {
|
||||
format!("\\({}\\)", &original.value[1..(original.value.len() - 1)])
|
||||
} else {
|
||||
original.value.to_owned()
|
||||
};
|
||||
Ok(ILatexFragment { value })
|
||||
});
|
||||
intermediate!(
|
||||
ILatexFragment,
|
||||
&'orig organic::types::LatexFragment<'parse>,
|
||||
original,
|
||||
_registry,
|
||||
{
|
||||
let value: String = if original.value.starts_with("$$") && original.value.ends_with("$$") {
|
||||
format!("\\[{}\\]", &original.value[2..(original.value.len() - 2)])
|
||||
} else if original.value.starts_with("$") && original.value.ends_with("$") {
|
||||
format!("\\({}\\)", &original.value[1..(original.value.len() - 1)])
|
||||
} else {
|
||||
original.value.to_owned()
|
||||
};
|
||||
Ok(ILatexFragment { value })
|
||||
}
|
||||
);
|
||||
|
@ -23,14 +23,12 @@ pub(crate) use inoop;
|
||||
///
|
||||
/// This exists to make changing the type signature easier.
|
||||
macro_rules! intermediate {
|
||||
($istruct:ident, $pstruct:ident, $original:ident, $registry:ident, $fnbody:tt) => {
|
||||
($istruct:ident, $pstruct:ty, $original:ident, $registry:ident, $fnbody:tt) => {
|
||||
impl $istruct {
|
||||
pub(crate) async fn new<'orig, 'parse>(
|
||||
registry: crate::intermediate::RefRegistry<'orig, 'parse>,
|
||||
original: &'orig organic::types::$pstruct<'parse>,
|
||||
$registry: crate::intermediate::RefRegistry<'orig, 'parse>,
|
||||
$original: $pstruct,
|
||||
) -> Result<$istruct, CustomError> {
|
||||
let $original = original;
|
||||
let $registry = registry;
|
||||
$fnbody
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,28 @@ use crate::error::CustomError;
|
||||
|
||||
use super::footnote_definition::IRealFootnoteDefinition;
|
||||
|
||||
use super::macros::intermediate;
|
||||
use super::IDocumentElement;
|
||||
use super::IHeading;
|
||||
use super::ISection;
|
||||
use super::RefRegistry;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct BlogPostPageInput<'b, 'parse> {
|
||||
path: PathBuf,
|
||||
document: &'b organic::types::Document<'parse>,
|
||||
}
|
||||
|
||||
impl<'b, 'parse> BlogPostPageInput<'b, 'parse> {
|
||||
pub(crate) fn new<P: Into<PathBuf>>(
|
||||
path: P,
|
||||
document: &'b organic::types::Document<'parse>,
|
||||
) -> BlogPostPageInput<'b, 'parse> {
|
||||
BlogPostPageInput {
|
||||
path: path.into(),
|
||||
document,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct BlogPostPage {
|
||||
@ -23,21 +41,19 @@ pub(crate) struct BlogPostPage {
|
||||
pub(crate) footnotes: Vec<IRealFootnoteDefinition>,
|
||||
}
|
||||
|
||||
impl BlogPostPage {
|
||||
// TODO: Move path into the registry so I can give this a standard interface like the others.
|
||||
pub(crate) async fn new<'a, 'b, 'parse, P: Into<PathBuf>>(
|
||||
path: P,
|
||||
registry: RefRegistry<'b, 'parse>,
|
||||
document: &'b organic::types::Document<'parse>,
|
||||
) -> Result<BlogPostPage, CustomError> {
|
||||
let path = path.into();
|
||||
intermediate!(
|
||||
BlogPostPage,
|
||||
BlogPostPageInput<'orig, 'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let mut children = Vec::new();
|
||||
if let Some(section) = document.zeroth_section.as_ref() {
|
||||
if let Some(section) = original.document.zeroth_section.as_ref() {
|
||||
children.push(IDocumentElement::Section(
|
||||
ISection::new(registry.clone(), section).await?,
|
||||
));
|
||||
}
|
||||
for heading in document.children.iter() {
|
||||
for heading in original.document.children.iter() {
|
||||
children.push(IDocumentElement::Heading(
|
||||
IHeading::new(registry.clone(), heading).await?,
|
||||
));
|
||||
@ -60,14 +76,16 @@ impl BlogPostPage {
|
||||
};
|
||||
|
||||
Ok(BlogPostPage {
|
||||
path,
|
||||
title: get_title(&document),
|
||||
date: get_date(&document),
|
||||
path: original.path,
|
||||
title: get_title(original.document),
|
||||
date: get_date(original.document),
|
||||
children,
|
||||
footnotes,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
impl BlogPostPage {
|
||||
/// Get the output path relative to the post directory.
|
||||
pub(crate) fn get_output_path(&self) -> PathBuf {
|
||||
let mut ret = self.path.clone();
|
||||
|
@ -8,14 +8,20 @@ pub(crate) struct IParagraph {
|
||||
pub(crate) children: Vec<IObject>,
|
||||
}
|
||||
|
||||
intermediate!(IParagraph, Paragraph, original, registry, {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IObject::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
intermediate!(
|
||||
IParagraph,
|
||||
&'orig organic::types::Paragraph<'parse>,
|
||||
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(IParagraph { children })
|
||||
});
|
||||
Ok(IParagraph { children })
|
||||
}
|
||||
);
|
||||
|
@ -9,17 +9,23 @@ pub(crate) struct IPlainList {
|
||||
pub(crate) children: Vec<IPlainListItem>,
|
||||
}
|
||||
|
||||
intermediate!(IPlainList, PlainList, original, registry, {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IPlainListItem::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
intermediate!(
|
||||
IPlainList,
|
||||
&'orig organic::types::PlainList<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IPlainListItem::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(IPlainList {
|
||||
list_type: original.list_type,
|
||||
children,
|
||||
})
|
||||
});
|
||||
Ok(IPlainList {
|
||||
list_type: original.list_type,
|
||||
children,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
@ -10,22 +10,28 @@ pub(crate) struct IPlainListItem {
|
||||
pub(crate) children: Vec<IElement>,
|
||||
}
|
||||
|
||||
intermediate!(IPlainListItem, PlainListItem, original, registry, {
|
||||
let tag = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.tag.iter() {
|
||||
ret.push(IObject::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
intermediate!(
|
||||
IPlainListItem,
|
||||
&'orig organic::types::PlainListItem<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let tag = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.tag.iter() {
|
||||
ret.push(IObject::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for elem in original.children.iter() {
|
||||
ret.push(IElement::new(registry.clone(), elem).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for elem in original.children.iter() {
|
||||
ret.push(IElement::new(registry.clone(), elem).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(IPlainListItem { tag, children })
|
||||
});
|
||||
Ok(IPlainListItem { tag, children })
|
||||
}
|
||||
);
|
||||
|
@ -8,8 +8,14 @@ pub(crate) struct IPlainText {
|
||||
pub(crate) source: String,
|
||||
}
|
||||
|
||||
intermediate!(IPlainText, PlainText, original, _registry, {
|
||||
Ok(IPlainText {
|
||||
source: coalesce_whitespace(original.source).into_owned(),
|
||||
})
|
||||
});
|
||||
intermediate!(
|
||||
IPlainText,
|
||||
&'orig organic::types::PlainText<'parse>,
|
||||
original,
|
||||
_registry,
|
||||
{
|
||||
Ok(IPlainText {
|
||||
source: coalesce_whitespace(original.source).into_owned(),
|
||||
})
|
||||
}
|
||||
);
|
||||
|
@ -8,14 +8,20 @@ pub(crate) struct IQuoteBlock {
|
||||
pub(crate) children: Vec<IElement>,
|
||||
}
|
||||
|
||||
intermediate!(IQuoteBlock, QuoteBlock, original, registry, {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IElement::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
intermediate!(
|
||||
IQuoteBlock,
|
||||
&'orig organic::types::QuoteBlock<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IElement::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(IQuoteBlock { children })
|
||||
});
|
||||
Ok(IQuoteBlock { children })
|
||||
}
|
||||
);
|
||||
|
@ -9,16 +9,22 @@ pub(crate) struct IRegularLink {
|
||||
pub(crate) children: Vec<IObject>,
|
||||
}
|
||||
|
||||
intermediate!(IRegularLink, RegularLink, 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(IRegularLink {
|
||||
raw_link: original.get_raw_link().into_owned(),
|
||||
children,
|
||||
})
|
||||
});
|
||||
intermediate!(
|
||||
IRegularLink,
|
||||
&'orig organic::types::RegularLink<'parse>,
|
||||
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(IRegularLink {
|
||||
raw_link: original.get_raw_link().into_owned(),
|
||||
children,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
@ -8,14 +8,20 @@ pub(crate) struct ISection {
|
||||
pub(crate) children: Vec<IElement>,
|
||||
}
|
||||
|
||||
intermediate!(ISection, Section, original, registry, {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for elem in original.children.iter() {
|
||||
ret.push(IElement::new(registry.clone(), elem).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
intermediate!(
|
||||
ISection,
|
||||
&'orig organic::types::Section<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for elem in original.children.iter() {
|
||||
ret.push(IElement::new(registry.clone(), elem).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(ISection { children })
|
||||
});
|
||||
Ok(ISection { children })
|
||||
}
|
||||
);
|
||||
|
@ -7,11 +7,17 @@ pub(crate) struct ISrcBlock {
|
||||
pub(crate) lines: Vec<String>,
|
||||
}
|
||||
|
||||
intermediate!(ISrcBlock, SrcBlock, original, _registry, {
|
||||
let lines = original
|
||||
.get_value()
|
||||
.split_inclusive('\n')
|
||||
.map(|s| s.to_owned())
|
||||
.collect();
|
||||
Ok(ISrcBlock { lines })
|
||||
});
|
||||
intermediate!(
|
||||
ISrcBlock,
|
||||
&'orig organic::types::SrcBlock<'parse>,
|
||||
original,
|
||||
_registry,
|
||||
{
|
||||
let lines = original
|
||||
.get_value()
|
||||
.split_inclusive('\n')
|
||||
.map(|s| s.to_owned())
|
||||
.collect();
|
||||
Ok(ISrcBlock { lines })
|
||||
}
|
||||
);
|
||||
|
@ -8,14 +8,20 @@ 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
|
||||
};
|
||||
intermediate!(
|
||||
IStrikeThrough,
|
||||
&'orig organic::types::StrikeThrough<'parse>,
|
||||
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 })
|
||||
});
|
||||
Ok(IStrikeThrough { children })
|
||||
}
|
||||
);
|
||||
|
@ -8,14 +8,20 @@ pub(crate) struct ITable {
|
||||
pub(crate) children: Vec<ITableRow>,
|
||||
}
|
||||
|
||||
intermediate!(ITable, Table, original, registry, {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(ITableRow::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
intermediate!(
|
||||
ITable,
|
||||
&'orig organic::types::Table<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(ITableRow::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(ITable { children })
|
||||
});
|
||||
Ok(ITable { children })
|
||||
}
|
||||
);
|
||||
|
@ -8,14 +8,20 @@ pub(crate) struct ITableCell {
|
||||
pub(crate) children: Vec<IObject>,
|
||||
}
|
||||
|
||||
intermediate!(ITableCell, TableCell, original, registry, {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IObject::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
intermediate!(
|
||||
ITableCell,
|
||||
&'orig organic::types::TableCell<'parse>,
|
||||
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(ITableCell { children })
|
||||
});
|
||||
Ok(ITableCell { children })
|
||||
}
|
||||
);
|
||||
|
@ -1,5 +1,4 @@
|
||||
use super::macros::intermediate;
|
||||
|
||||
use super::table_cell::ITableCell;
|
||||
use crate::error::CustomError;
|
||||
|
||||
@ -8,14 +7,20 @@ pub(crate) struct ITableRow {
|
||||
pub(crate) children: Vec<ITableCell>,
|
||||
}
|
||||
|
||||
intermediate!(ITableRow, TableRow, original, registry, {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(ITableCell::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
intermediate!(
|
||||
ITableRow,
|
||||
&'orig organic::types::TableRow<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(ITableCell::new(registry.clone(), obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(ITableRow { children })
|
||||
});
|
||||
Ok(ITableRow { children })
|
||||
}
|
||||
);
|
||||
|
@ -8,11 +8,17 @@ pub(crate) struct ITarget {
|
||||
value: String,
|
||||
}
|
||||
|
||||
intermediate!(ITarget, Target, original, registry, {
|
||||
let mut registry = registry.lock().unwrap();
|
||||
let id = registry.get_target(original.value);
|
||||
Ok(ITarget {
|
||||
id: id.clone(),
|
||||
value: original.value.to_owned(),
|
||||
})
|
||||
});
|
||||
intermediate!(
|
||||
ITarget,
|
||||
&'orig organic::types::Target<'parse>,
|
||||
original,
|
||||
registry,
|
||||
{
|
||||
let mut registry = registry.lock().unwrap();
|
||||
let id = registry.get_target(original.value);
|
||||
Ok(ITarget {
|
||||
id: id.clone(),
|
||||
value: original.value.to_owned(),
|
||||
})
|
||||
}
|
||||
);
|
||||
|
@ -8,14 +8,20 @@ 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
|
||||
};
|
||||
intermediate!(
|
||||
IUnderline,
|
||||
&'orig organic::types::Underline<'parse>,
|
||||
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(IUnderline { children })
|
||||
});
|
||||
Ok(IUnderline { children })
|
||||
}
|
||||
);
|
||||
|
@ -7,9 +7,15 @@ pub(crate) struct IVerbatim {
|
||||
pub(crate) contents: String,
|
||||
}
|
||||
|
||||
intermediate!(IVerbatim, Verbatim, original, _registry, {
|
||||
Ok(IVerbatim {
|
||||
// TODO: Should this coalesce whitespace like PlainText?
|
||||
contents: original.contents.to_owned(),
|
||||
})
|
||||
});
|
||||
intermediate!(
|
||||
IVerbatim,
|
||||
&'orig organic::types::Verbatim<'parse>,
|
||||
original,
|
||||
_registry,
|
||||
{
|
||||
Ok(IVerbatim {
|
||||
// TODO: Should this coalesce whitespace like PlainText?
|
||||
contents: original.contents.to_owned(),
|
||||
})
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user