natter/src/intermediate/heading.rs
Tom Alexander 8b85c02ef1
Wrap the intermediate Registry in an IntermediateContext.
This is currently just to maintain consistency with the render phase's RenderContext but in the future it should allow us to include immutable data that is not locked behind the ArcMutex.
2023-12-21 13:53:56 -05:00

41 lines
1020 B
Rust

use super::macros::intermediate;
use super::IDocumentElement;
use super::IObject;
use crate::error::CustomError;
#[derive(Debug, Clone)]
pub(crate) struct IHeading {
pub(crate) level: organic::types::HeadlineLevel,
pub(crate) title: Vec<IObject>,
pub(crate) children: Vec<IDocumentElement>,
}
intermediate!(
IHeading,
&'orig organic::types::Heading<'parse>,
original,
intermediate_context,
{
let title = {
let mut ret = Vec::new();
for obj in original.title.iter() {
ret.push(IObject::new(intermediate_context.clone(), obj).await?);
}
ret
};
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(IDocumentElement::new(intermediate_context.clone(), obj).await?);
}
ret
};
Ok(IHeading {
title,
level: original.level,
children,
})
}
);