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