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.
This commit is contained in:
Tom Alexander 2023-12-21 13:53:56 -05:00
parent 2ae4839ce0
commit 8b85c02ef1
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
34 changed files with 266 additions and 229 deletions

View File

@ -18,7 +18,6 @@ use super::plain_link::IPlainLink;
use super::plain_text::IPlainText; use super::plain_text::IPlainText;
use super::radio_link::IRadioLink; use super::radio_link::IRadioLink;
use super::radio_target::IRadioTarget; use super::radio_target::IRadioTarget;
use super::regular_link::IRegularLink; use super::regular_link::IRegularLink;
use super::statistics_cookie::IStatisticsCookie; use super::statistics_cookie::IStatisticsCookie;
use super::strike_through::IStrikeThrough; use super::strike_through::IStrikeThrough;
@ -52,7 +51,7 @@ use super::ITimestamp;
use super::IUnderline; use super::IUnderline;
use super::IVerbatim; use super::IVerbatim;
use super::IVerseBlock; use super::IVerseBlock;
use super::RefRegistry; use super::IntermediateContext;
use crate::error::CustomError; use crate::error::CustomError;
use futures::future::{BoxFuture, FutureExt}; use futures::future::{BoxFuture, FutureExt};
@ -116,23 +115,23 @@ pub(crate) enum IAstNode {
pub(crate) trait IntoIAstNode<'parse> { pub(crate) trait IntoIAstNode<'parse> {
fn into_ast_node<'orig>( fn into_ast_node<'orig>(
&'orig self, &'orig self,
registry: RefRegistry<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
) -> BoxFuture<'orig, Result<IAstNode, CustomError>>; ) -> BoxFuture<'orig, Result<IAstNode, CustomError>>;
} }
impl<'parse> IntoIAstNode<'parse> for organic::types::DocumentElement<'parse> { impl<'parse> IntoIAstNode<'parse> for organic::types::DocumentElement<'parse> {
fn into_ast_node<'orig>( fn into_ast_node<'orig>(
&'orig self, &'orig self,
registry: RefRegistry<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
) -> BoxFuture<'orig, Result<IAstNode, CustomError>> { ) -> BoxFuture<'orig, Result<IAstNode, CustomError>> {
async move { async move {
match self { match self {
organic::types::DocumentElement::Heading(inner) => { organic::types::DocumentElement::Heading(inner) => Ok(IAstNode::Heading(
Ok(IAstNode::Heading(IHeading::new(registry, inner).await?)) IHeading::new(intermediate_context, inner).await?,
} )),
organic::types::DocumentElement::Section(inner) => { organic::types::DocumentElement::Section(inner) => Ok(IAstNode::Section(
Ok(IAstNode::Section(ISection::new(registry, inner).await?)) ISection::new(intermediate_context, inner).await?,
} )),
} }
} }
.boxed() .boxed()
@ -142,81 +141,83 @@ impl<'parse> IntoIAstNode<'parse> for organic::types::DocumentElement<'parse> {
impl<'parse> IntoIAstNode<'parse> for organic::types::Element<'parse> { impl<'parse> IntoIAstNode<'parse> for organic::types::Element<'parse> {
fn into_ast_node<'orig>( fn into_ast_node<'orig>(
&'orig self, &'orig self,
registry: RefRegistry<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
) -> BoxFuture<'orig, Result<IAstNode, CustomError>> { ) -> BoxFuture<'orig, Result<IAstNode, CustomError>> {
async move { async move {
match self { match self {
organic::types::Element::Paragraph(inner) => { organic::types::Element::Paragraph(inner) => Ok(IAstNode::Paragraph(
Ok(IAstNode::Paragraph(IParagraph::new(registry, inner).await?)) IParagraph::new(intermediate_context, inner).await?,
} )),
organic::types::Element::PlainList(inner) => { organic::types::Element::PlainList(inner) => Ok(IAstNode::PlainList(
Ok(IAstNode::PlainList(IPlainList::new(registry, inner).await?)) IPlainList::new(intermediate_context, inner).await?,
} )),
organic::types::Element::CenterBlock(inner) => Ok(IAstNode::CenterBlock( organic::types::Element::CenterBlock(inner) => Ok(IAstNode::CenterBlock(
ICenterBlock::new(registry, inner).await?, ICenterBlock::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::QuoteBlock(inner) => Ok(IAstNode::QuoteBlock( organic::types::Element::QuoteBlock(inner) => Ok(IAstNode::QuoteBlock(
IQuoteBlock::new(registry, inner).await?, IQuoteBlock::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::SpecialBlock(inner) => Ok(IAstNode::SpecialBlock( organic::types::Element::SpecialBlock(inner) => Ok(IAstNode::SpecialBlock(
ISpecialBlock::new(registry, inner).await?, ISpecialBlock::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::DynamicBlock(inner) => Ok(IAstNode::DynamicBlock( organic::types::Element::DynamicBlock(inner) => Ok(IAstNode::DynamicBlock(
IDynamicBlock::new(registry, inner).await?, IDynamicBlock::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::FootnoteDefinition(inner) => Ok( organic::types::Element::FootnoteDefinition(inner) => {
IAstNode::FootnoteDefinition(IFootnoteDefinition::new(registry, inner).await?), Ok(IAstNode::FootnoteDefinition(
), IFootnoteDefinition::new(intermediate_context, inner).await?,
organic::types::Element::Comment(inner) => { ))
Ok(IAstNode::Comment(IComment::new(registry, inner).await?))
}
organic::types::Element::Drawer(inner) => {
Ok(IAstNode::Drawer(IDrawer::new(registry, inner).await?))
} }
organic::types::Element::Comment(inner) => Ok(IAstNode::Comment(
IComment::new(intermediate_context, inner).await?,
)),
organic::types::Element::Drawer(inner) => Ok(IAstNode::Drawer(
IDrawer::new(intermediate_context, inner).await?,
)),
organic::types::Element::PropertyDrawer(inner) => Ok(IAstNode::PropertyDrawer( organic::types::Element::PropertyDrawer(inner) => Ok(IAstNode::PropertyDrawer(
IPropertyDrawer::new(registry, inner).await?, IPropertyDrawer::new(intermediate_context, inner).await?,
)),
organic::types::Element::Table(inner) => Ok(IAstNode::Table(
ITable::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::Table(inner) => {
Ok(IAstNode::Table(ITable::new(registry, inner).await?))
}
organic::types::Element::VerseBlock(inner) => Ok(IAstNode::VerseBlock( organic::types::Element::VerseBlock(inner) => Ok(IAstNode::VerseBlock(
IVerseBlock::new(registry, inner).await?, IVerseBlock::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::CommentBlock(inner) => Ok(IAstNode::CommentBlock( organic::types::Element::CommentBlock(inner) => Ok(IAstNode::CommentBlock(
ICommentBlock::new(registry, inner).await?, ICommentBlock::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::ExampleBlock(inner) => Ok(IAstNode::ExampleBlock( organic::types::Element::ExampleBlock(inner) => Ok(IAstNode::ExampleBlock(
IExampleBlock::new(registry, inner).await?, IExampleBlock::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::ExportBlock(inner) => Ok(IAstNode::ExportBlock( organic::types::Element::ExportBlock(inner) => Ok(IAstNode::ExportBlock(
IExportBlock::new(registry, inner).await?, IExportBlock::new(intermediate_context, inner).await?,
)),
organic::types::Element::SrcBlock(inner) => Ok(IAstNode::SrcBlock(
ISrcBlock::new(intermediate_context, inner).await?,
)),
organic::types::Element::Clock(inner) => Ok(IAstNode::Clock(
IClock::new(intermediate_context, inner).await?,
)),
organic::types::Element::DiarySexp(inner) => Ok(IAstNode::DiarySexp(
IDiarySexp::new(intermediate_context, inner).await?,
)),
organic::types::Element::Planning(inner) => Ok(IAstNode::Planning(
IPlanning::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::SrcBlock(inner) => {
Ok(IAstNode::SrcBlock(ISrcBlock::new(registry, inner).await?))
}
organic::types::Element::Clock(inner) => {
Ok(IAstNode::Clock(IClock::new(registry, inner).await?))
}
organic::types::Element::DiarySexp(inner) => {
Ok(IAstNode::DiarySexp(IDiarySexp::new(registry, inner).await?))
}
organic::types::Element::Planning(inner) => {
Ok(IAstNode::Planning(IPlanning::new(registry, inner).await?))
}
organic::types::Element::FixedWidthArea(inner) => Ok(IAstNode::FixedWidthArea( organic::types::Element::FixedWidthArea(inner) => Ok(IAstNode::FixedWidthArea(
IFixedWidthArea::new(registry, inner).await?, IFixedWidthArea::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::HorizontalRule(inner) => Ok(IAstNode::HorizontalRule( organic::types::Element::HorizontalRule(inner) => Ok(IAstNode::HorizontalRule(
IHorizontalRule::new(registry, inner).await?, IHorizontalRule::new(intermediate_context, inner).await?,
)),
organic::types::Element::Keyword(inner) => Ok(IAstNode::Keyword(
IKeyword::new(intermediate_context, inner).await?,
)),
organic::types::Element::BabelCall(inner) => Ok(IAstNode::BabelCall(
IBabelCall::new(intermediate_context, inner).await?,
)), )),
organic::types::Element::Keyword(inner) => {
Ok(IAstNode::Keyword(IKeyword::new(registry, inner).await?))
}
organic::types::Element::BabelCall(inner) => {
Ok(IAstNode::BabelCall(IBabelCall::new(registry, inner).await?))
}
organic::types::Element::LatexEnvironment(inner) => Ok(IAstNode::LatexEnvironment( organic::types::Element::LatexEnvironment(inner) => Ok(IAstNode::LatexEnvironment(
ILatexEnvironment::new(registry, inner).await?, ILatexEnvironment::new(intermediate_context, inner).await?,
)), )),
} }
} }
@ -227,91 +228,97 @@ impl<'parse> IntoIAstNode<'parse> for organic::types::Element<'parse> {
impl<'parse> IntoIAstNode<'parse> for organic::types::Object<'parse> { impl<'parse> IntoIAstNode<'parse> for organic::types::Object<'parse> {
fn into_ast_node<'orig>( fn into_ast_node<'orig>(
&'orig self, &'orig self,
registry: RefRegistry<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
) -> BoxFuture<'orig, Result<IAstNode, CustomError>> { ) -> BoxFuture<'orig, Result<IAstNode, CustomError>> {
async move { async move {
match self { match self {
organic::types::Object::Bold(inner) => { organic::types::Object::Bold(inner) => Ok(IAstNode::Bold(
Ok(IAstNode::Bold(IBold::new(registry, inner).await?)) IBold::new(intermediate_context, inner).await?,
} )),
organic::types::Object::Italic(inner) => { organic::types::Object::Italic(inner) => Ok(IAstNode::Italic(
Ok(IAstNode::Italic(IItalic::new(registry, inner).await?)) IItalic::new(intermediate_context, inner).await?,
} )),
organic::types::Object::Underline(inner) => { organic::types::Object::Underline(inner) => Ok(IAstNode::Underline(
Ok(IAstNode::Underline(IUnderline::new(registry, inner).await?)) IUnderline::new(intermediate_context, inner).await?,
} )),
organic::types::Object::StrikeThrough(inner) => Ok(IAstNode::StrikeThrough( organic::types::Object::StrikeThrough(inner) => Ok(IAstNode::StrikeThrough(
IStrikeThrough::new(registry, inner).await?, IStrikeThrough::new(intermediate_context, inner).await?,
)),
organic::types::Object::Code(inner) => Ok(IAstNode::Code(
ICode::new(intermediate_context, inner).await?,
)),
organic::types::Object::Verbatim(inner) => Ok(IAstNode::Verbatim(
IVerbatim::new(intermediate_context, inner).await?,
)),
organic::types::Object::PlainText(inner) => Ok(IAstNode::PlainText(
IPlainText::new(intermediate_context, inner).await?,
)), )),
organic::types::Object::Code(inner) => {
Ok(IAstNode::Code(ICode::new(registry, inner).await?))
}
organic::types::Object::Verbatim(inner) => {
Ok(IAstNode::Verbatim(IVerbatim::new(registry, inner).await?))
}
organic::types::Object::PlainText(inner) => {
Ok(IAstNode::PlainText(IPlainText::new(registry, inner).await?))
}
organic::types::Object::RegularLink(inner) => Ok(IAstNode::RegularLink( organic::types::Object::RegularLink(inner) => Ok(IAstNode::RegularLink(
IRegularLink::new(registry, inner).await?, IRegularLink::new(intermediate_context, inner).await?,
)),
organic::types::Object::RadioLink(inner) => Ok(IAstNode::RadioLink(
IRadioLink::new(intermediate_context, inner).await?,
)), )),
organic::types::Object::RadioLink(inner) => {
Ok(IAstNode::RadioLink(IRadioLink::new(registry, inner).await?))
}
organic::types::Object::RadioTarget(inner) => Ok(IAstNode::RadioTarget( organic::types::Object::RadioTarget(inner) => Ok(IAstNode::RadioTarget(
IRadioTarget::new(registry, inner).await?, IRadioTarget::new(intermediate_context, inner).await?,
)),
organic::types::Object::PlainLink(inner) => Ok(IAstNode::PlainLink(
IPlainLink::new(intermediate_context, inner).await?,
)),
organic::types::Object::AngleLink(inner) => Ok(IAstNode::AngleLink(
IAngleLink::new(intermediate_context, inner).await?,
)),
organic::types::Object::OrgMacro(inner) => Ok(IAstNode::OrgMacro(
IOrgMacro::new(intermediate_context, inner).await?,
)),
organic::types::Object::Entity(inner) => Ok(IAstNode::Entity(
IEntity::new(intermediate_context, inner).await?,
)), )),
organic::types::Object::PlainLink(inner) => {
Ok(IAstNode::PlainLink(IPlainLink::new(registry, inner).await?))
}
organic::types::Object::AngleLink(inner) => {
Ok(IAstNode::AngleLink(IAngleLink::new(registry, inner).await?))
}
organic::types::Object::OrgMacro(inner) => {
Ok(IAstNode::OrgMacro(IOrgMacro::new(registry, inner).await?))
}
organic::types::Object::Entity(inner) => {
Ok(IAstNode::Entity(IEntity::new(registry, inner).await?))
}
organic::types::Object::LatexFragment(inner) => Ok(IAstNode::LatexFragment( organic::types::Object::LatexFragment(inner) => Ok(IAstNode::LatexFragment(
ILatexFragment::new(registry, inner).await?, ILatexFragment::new(intermediate_context, inner).await?,
)), )),
organic::types::Object::ExportSnippet(inner) => Ok(IAstNode::ExportSnippet( organic::types::Object::ExportSnippet(inner) => Ok(IAstNode::ExportSnippet(
IExportSnippet::new(registry, inner).await?, IExportSnippet::new(intermediate_context, inner).await?,
)), )),
organic::types::Object::FootnoteReference(inner) => Ok( organic::types::Object::FootnoteReference(inner) => {
IAstNode::FootnoteReference(IFootnoteReference::new(registry, inner).await?), Ok(IAstNode::FootnoteReference(
), IFootnoteReference::new(intermediate_context, inner).await?,
organic::types::Object::Citation(inner) => { ))
Ok(IAstNode::Citation(ICitation::new(registry, inner).await?)) }
organic::types::Object::Citation(inner) => Ok(IAstNode::Citation(
ICitation::new(intermediate_context, inner).await?,
)),
organic::types::Object::CitationReference(inner) => {
Ok(IAstNode::CitationReference(
ICitationReference::new(intermediate_context, inner).await?,
))
} }
organic::types::Object::CitationReference(inner) => Ok(
IAstNode::CitationReference(ICitationReference::new(registry, inner).await?),
),
organic::types::Object::InlineBabelCall(inner) => Ok(IAstNode::InlineBabelCall( organic::types::Object::InlineBabelCall(inner) => Ok(IAstNode::InlineBabelCall(
IInlineBabelCall::new(registry, inner).await?, IInlineBabelCall::new(intermediate_context, inner).await?,
)), )),
organic::types::Object::InlineSourceBlock(inner) => Ok( organic::types::Object::InlineSourceBlock(inner) => {
IAstNode::InlineSourceBlock(IInlineSourceBlock::new(registry, inner).await?), Ok(IAstNode::InlineSourceBlock(
), IInlineSourceBlock::new(intermediate_context, inner).await?,
organic::types::Object::LineBreak(inner) => { ))
Ok(IAstNode::LineBreak(ILineBreak::new(registry, inner).await?))
}
organic::types::Object::Target(inner) => {
Ok(IAstNode::Target(ITarget::new(registry, inner).await?))
} }
organic::types::Object::LineBreak(inner) => Ok(IAstNode::LineBreak(
ILineBreak::new(intermediate_context, inner).await?,
)),
organic::types::Object::Target(inner) => Ok(IAstNode::Target(
ITarget::new(intermediate_context, inner).await?,
)),
organic::types::Object::StatisticsCookie(inner) => Ok(IAstNode::StatisticsCookie( organic::types::Object::StatisticsCookie(inner) => Ok(IAstNode::StatisticsCookie(
IStatisticsCookie::new(registry, inner).await?, IStatisticsCookie::new(intermediate_context, inner).await?,
)),
organic::types::Object::Subscript(inner) => Ok(IAstNode::Subscript(
ISubscript::new(intermediate_context, inner).await?,
)), )),
organic::types::Object::Subscript(inner) => {
Ok(IAstNode::Subscript(ISubscript::new(registry, inner).await?))
}
organic::types::Object::Superscript(inner) => Ok(IAstNode::Superscript( organic::types::Object::Superscript(inner) => Ok(IAstNode::Superscript(
ISuperscript::new(registry, inner).await?, ISuperscript::new(intermediate_context, inner).await?,
)),
organic::types::Object::Timestamp(inner) => Ok(IAstNode::Timestamp(
ITimestamp::new(intermediate_context, inner).await?,
)), )),
organic::types::Object::Timestamp(inner) => {
Ok(IAstNode::Timestamp(ITimestamp::new(registry, inner).await?))
}
} }
} }
.boxed() .boxed()

View File

@ -9,6 +9,7 @@ use walkdir::WalkDir;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::page::BlogPostPageInput; use crate::intermediate::page::BlogPostPageInput;
use crate::intermediate::registry::Registry; use crate::intermediate::registry::Registry;
use crate::intermediate::IntermediateContext;
use super::BlogPostPage; use super::BlogPostPage;
@ -62,10 +63,11 @@ impl BlogPost {
}); });
let registry = Arc::new(Mutex::new(registry)); let registry = Arc::new(Mutex::new(registry));
let intermediate_context = IntermediateContext::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( BlogPostPage::new(
registry, intermediate_context,
BlogPostPageInput::new(relative_to_post_dir_path, parsed_document), BlogPostPageInput::new(relative_to_post_dir_path, parsed_document),
) )
.await?, .await?,

View File

@ -12,12 +12,12 @@ intermediate!(
IBold, IBold,
&'orig organic::types::Bold<'parse>, &'orig organic::types::Bold<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IObject::new(registry.clone(), obj).await?); ret.push(IObject::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -11,7 +11,7 @@ intermediate!(
ICode, ICode,
&'orig organic::types::Code<'parse>, &'orig organic::types::Code<'parse>,
original, original,
_registry, _intermediate_context,
{ {
Ok(ICode { Ok(ICode {
// TODO: Should this coalesce whitespace like PlainText? // TODO: Should this coalesce whitespace like PlainText?

View File

@ -12,19 +12,25 @@ pub(crate) enum IDocumentElement {
Section(ISection), Section(ISection),
} }
iselector!(IDocumentElement, DocumentElement, original, registry, { iselector!(
iitem!( IDocumentElement,
registry, DocumentElement,
original, original,
( intermediate_context,
organic::types::DocumentElement::Heading, {
IDocumentElement::Heading, iitem!(
IHeading intermediate_context,
), original,
( (
organic::types::DocumentElement::Section, organic::types::DocumentElement::Heading,
IDocumentElement::Section, IDocumentElement::Heading,
ISection IHeading
), ),
) (
}); organic::types::DocumentElement::Section,
IDocumentElement::Section,
ISection
),
)
}
);

View File

@ -56,9 +56,9 @@ pub(crate) enum IElement {
LatexEnvironment(ILatexEnvironment), LatexEnvironment(ILatexEnvironment),
} }
iselector!(IElement, Element, original, registry, { iselector!(IElement, Element, original, intermediate_context, {
iitem!( iitem!(
registry, intermediate_context,
original, original,
( (
organic::types::Element::Paragraph, organic::types::Element::Paragraph,

View File

@ -11,7 +11,7 @@ intermediate!(
IEntity, IEntity,
&'orig organic::types::Entity<'parse>, &'orig organic::types::Entity<'parse>,
original, original,
_registry, _intermediate_context,
{ {
Ok(IEntity { Ok(IEntity {
html: original.html.to_owned(), html: original.html.to_owned(),

View File

@ -1,9 +1,9 @@
use super::macros::intermediate; use super::macros::intermediate;
use super::registry::register_footnote_definition; use super::registry::register_footnote_definition;
use super::IntermediateContext;
use super::IAstNode; use super::IAstNode;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::RefRegistry;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub(crate) struct IFootnoteDefinition {} pub(crate) struct IFootnoteDefinition {}
@ -12,9 +12,10 @@ intermediate!(
IFootnoteDefinition, IFootnoteDefinition,
&'orig organic::types::FootnoteDefinition<'parse>, &'orig organic::types::FootnoteDefinition<'parse>,
original, original,
registry, intermediate_context,
{ {
register_footnote_definition(registry, original.label, &original.children).await?; register_footnote_definition(intermediate_context, original.label, &original.children)
.await?;
Ok(IFootnoteDefinition {}) Ok(IFootnoteDefinition {})
} }
); );
@ -27,7 +28,7 @@ pub(crate) struct IRealFootnoteDefinition {
impl IRealFootnoteDefinition { impl IRealFootnoteDefinition {
pub(crate) async fn new<'orig, 'parse>( pub(crate) async fn new<'orig, 'parse>(
_registry: RefRegistry<'orig, 'parse>, _intermediate_context: IntermediateContext<'orig, 'parse>,
footnote_id: usize, footnote_id: usize,
contents: Vec<IAstNode>, contents: Vec<IAstNode>,
) -> Result<IRealFootnoteDefinition, CustomError> { ) -> Result<IRealFootnoteDefinition, CustomError> {

View File

@ -13,10 +13,11 @@ intermediate!(
IFootnoteReference, IFootnoteReference,
&'orig organic::types::FootnoteReference<'parse>, &'orig organic::types::FootnoteReference<'parse>,
original, original,
registry, intermediate_context,
{ {
let (footnote_id, reference_count) = let (footnote_id, reference_count) =
get_footnote_reference_id(registry, original.label, &original.definition).await?; get_footnote_reference_id(intermediate_context, original.label, &original.definition)
.await?;
Ok(IFootnoteReference { Ok(IFootnoteReference {
footnote_id, footnote_id,
duplicate_offset: reference_count, duplicate_offset: reference_count,

View File

@ -15,19 +15,19 @@ intermediate!(
IHeading, IHeading,
&'orig organic::types::Heading<'parse>, &'orig organic::types::Heading<'parse>,
original, original,
registry, intermediate_context,
{ {
let title = { let title = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.title.iter() { for obj in original.title.iter() {
ret.push(IObject::new(registry.clone(), obj).await?); ret.push(IObject::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IDocumentElement::new(registry.clone(), obj).await?); ret.push(IDocumentElement::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -11,7 +11,7 @@ intermediate!(
IInlineSourceBlock, IInlineSourceBlock,
&'orig organic::types::InlineSourceBlock<'parse>, &'orig organic::types::InlineSourceBlock<'parse>,
original, original,
_registry, _intermediate_context,
{ {
Ok(IInlineSourceBlock { Ok(IInlineSourceBlock {
value: original.value.to_owned(), value: original.value.to_owned(),

View File

@ -0,0 +1,15 @@
use crate::error::CustomError;
/// The supporting information used for converting the parsed org source representation into the intermediate representation used in this project.
#[derive(Debug, Clone)]
pub(crate) struct IntermediateContext<'orig, 'parse> {
pub(crate) registry: crate::intermediate::RefRegistry<'orig, 'parse>,
}
impl<'orig, 'parse> IntermediateContext<'orig, 'parse> {
pub(crate) fn new(
registry: crate::intermediate::RefRegistry<'orig, 'parse>,
) -> Result<IntermediateContext<'orig, 'parse>, CustomError> {
Ok(IntermediateContext { registry })
}
}

View File

@ -12,12 +12,12 @@ intermediate!(
IItalic, IItalic,
&'orig organic::types::Italic<'parse>, &'orig organic::types::Italic<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IObject::new(registry.clone(), obj).await?); ret.push(IObject::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -11,7 +11,7 @@ intermediate!(
ILatexFragment, ILatexFragment,
&'orig organic::types::LatexFragment<'parse>, &'orig organic::types::LatexFragment<'parse>,
original, original,
_registry, _intermediate_context,
{ {
let value: String = if original.value.starts_with("$$") && original.value.ends_with("$$") { let value: String = if original.value.starts_with("$$") && original.value.ends_with("$$") {
format!("\\[{}\\]", &original.value[2..(original.value.len() - 2)]) format!("\\[{}\\]", &original.value[2..(original.value.len() - 2)])

View File

@ -8,7 +8,7 @@ macro_rules! inoop {
impl $istruct { impl $istruct {
pub(crate) async fn new<'reg, 'orig, 'parse>( pub(crate) async fn new<'reg, 'orig, 'parse>(
_registry: crate::intermediate::RefRegistry<'orig, 'parse>, _intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
_original: &'orig organic::types::$pstruct<'parse>, _original: &'orig organic::types::$pstruct<'parse>,
) -> Result<$istruct, CustomError> { ) -> Result<$istruct, CustomError> {
Ok($istruct {}) Ok($istruct {})
@ -23,10 +23,10 @@ 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:ty, $original:ident, $registry:ident, $fnbody:tt) => { ($istruct:ident, $pstruct:ty, $original:ident, $intermediate_context: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>, $intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
$original: $pstruct, $original: $pstruct,
) -> Result<$istruct, CustomError> { ) -> Result<$istruct, CustomError> {
$fnbody $fnbody
@ -41,14 +41,12 @@ pub(crate) use intermediate;
/// ///
/// This exists to make changing the type signature easier. /// This exists to make changing the type signature easier.
macro_rules! iselector { macro_rules! iselector {
($istruct:ident, $pstruct:ident, $original:ident, $registry:ident, $fnbody:tt) => { ($istruct:ident, $pstruct:ident, $original:ident, $intermediate_context:ident, $fnbody:tt) => {
impl $istruct { impl $istruct {
pub(crate) fn new<'orig, 'parse>( pub(crate) fn new<'orig, 'parse>(
registry: crate::intermediate::RefRegistry<'orig, 'parse>, $intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
original: &'orig organic::types::$pstruct<'parse>, $original: &'orig organic::types::$pstruct<'parse>,
) -> BoxFuture<'orig, Result<$istruct, CustomError>> { ) -> BoxFuture<'orig, Result<$istruct, CustomError>> {
let $registry = registry;
let $original = original;
async move { $fnbody }.boxed() async move { $fnbody }.boxed()
} }
} }
@ -58,11 +56,11 @@ macro_rules! iselector {
pub(crate) use iselector; pub(crate) use iselector;
macro_rules! iitem { macro_rules! iitem {
($registry:expr, $original:expr, $(($penum:path, $ienum:path, $istruct:ident),)*) => { ($intermediate_context:expr, $original:expr, $(($penum:path, $ienum:path, $istruct:ident),)*) => {
match $original { match $original {
$( $(
$penum(inner) => Ok($ienum( $penum(inner) => Ok($ienum(
$istruct::new($registry.clone(), inner).await?, $istruct::new($intermediate_context.clone(), inner).await?,
)), )),
)* )*
} }

View File

@ -27,6 +27,7 @@ mod heading;
mod horizontal_rule; mod horizontal_rule;
mod inline_babel_call; mod inline_babel_call;
mod inline_source_block; mod inline_source_block;
mod intermediate_context;
mod italic; mod italic;
mod keyword; mod keyword;
mod latex_environment; mod latex_environment;
@ -94,6 +95,7 @@ pub(crate) use heading::IHeading;
pub(crate) use horizontal_rule::IHorizontalRule; pub(crate) use horizontal_rule::IHorizontalRule;
pub(crate) use inline_babel_call::IInlineBabelCall; pub(crate) use inline_babel_call::IInlineBabelCall;
pub(crate) use inline_source_block::IInlineSourceBlock; pub(crate) use inline_source_block::IInlineSourceBlock;
pub(crate) use intermediate_context::IntermediateContext;
pub(crate) use italic::IItalic; pub(crate) use italic::IItalic;
pub(crate) use keyword::IKeyword; pub(crate) use keyword::IKeyword;
pub(crate) use latex_environment::ILatexEnvironment; pub(crate) use latex_environment::ILatexEnvironment;

View File

@ -63,9 +63,9 @@ pub(crate) enum IObject {
Timestamp(ITimestamp), Timestamp(ITimestamp),
} }
iselector!(IObject, Object, original, registry, { iselector!(IObject, Object, original, intermediate_context, {
iitem!( iitem!(
registry, intermediate_context,
original, original,
(organic::types::Object::Bold, IObject::Bold, IBold), (organic::types::Object::Bold, IObject::Bold, IBold),
(organic::types::Object::Italic, IObject::Italic, IItalic), (organic::types::Object::Italic, IObject::Italic, IItalic),

View File

@ -45,23 +45,23 @@ intermediate!(
BlogPostPage, BlogPostPage,
BlogPostPageInput<'orig, 'parse>, BlogPostPageInput<'orig, 'parse>,
original, original,
registry, intermediate_context,
{ {
let mut children = Vec::new(); let mut children = Vec::new();
if let Some(section) = original.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(intermediate_context.clone(), section).await?,
)); ));
} }
for heading in original.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(intermediate_context.clone(), heading).await?,
)); ));
} }
let footnotes = { let footnotes = {
let footnote_definitions: Vec<_> = { let footnote_definitions: Vec<_> = {
let registry = registry.lock().unwrap(); let registry = intermediate_context.registry.lock().unwrap();
let ret = registry let ret = registry
.get_footnote_ids() .get_footnote_ids()
.map(|(id, def)| (id, def.clone())) .map(|(id, def)| (id, def.clone()))
@ -70,7 +70,9 @@ intermediate!(
}; };
let mut ret = Vec::new(); let mut ret = Vec::new();
for (id, def) in footnote_definitions.into_iter() { for (id, def) in footnote_definitions.into_iter() {
ret.push(IRealFootnoteDefinition::new(registry.clone(), id, def).await?); ret.push(
IRealFootnoteDefinition::new(intermediate_context.clone(), id, def).await?,
);
} }
ret ret
}; };

View File

@ -12,12 +12,12 @@ intermediate!(
IParagraph, IParagraph,
&'orig organic::types::Paragraph<'parse>, &'orig organic::types::Paragraph<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IObject::new(registry.clone(), obj).await?); ret.push(IObject::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -13,12 +13,12 @@ intermediate!(
IPlainList, IPlainList,
&'orig organic::types::PlainList<'parse>, &'orig organic::types::PlainList<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IPlainListItem::new(registry.clone(), obj).await?); ret.push(IPlainListItem::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -14,12 +14,12 @@ intermediate!(
IPlainListItem, IPlainListItem,
&'orig organic::types::PlainListItem<'parse>, &'orig organic::types::PlainListItem<'parse>,
original, original,
registry, intermediate_context,
{ {
let tag = { let tag = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.tag.iter() { for obj in original.tag.iter() {
ret.push(IObject::new(registry.clone(), obj).await?); ret.push(IObject::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };
@ -27,7 +27,7 @@ intermediate!(
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(intermediate_context.clone(), elem).await?);
} }
ret ret
}; };

View File

@ -12,7 +12,7 @@ intermediate!(
IPlainText, IPlainText,
&'orig organic::types::PlainText<'parse>, &'orig organic::types::PlainText<'parse>,
original, original,
_registry, _intermediate_context,
{ {
Ok(IPlainText { Ok(IPlainText {
source: coalesce_whitespace(original.source).into_owned(), source: coalesce_whitespace(original.source).into_owned(),

View File

@ -12,12 +12,12 @@ intermediate!(
IQuoteBlock, IQuoteBlock,
&'orig organic::types::QuoteBlock<'parse>, &'orig organic::types::QuoteBlock<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IElement::new(registry.clone(), obj).await?); ret.push(IElement::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -5,10 +5,11 @@ use std::collections::HashMap;
use super::ast_node::IAstNode; use super::ast_node::IAstNode;
use super::ast_node::IntoIAstNode; use super::ast_node::IntoIAstNode;
use super::RefRegistry; use super::IntermediateContext;
type IdCounter = u16; type IdCounter = u16;
#[derive(Debug)]
pub(crate) struct Registry<'orig, 'parse> { pub(crate) struct Registry<'orig, 'parse> {
id_counter: IdCounter, id_counter: IdCounter,
targets: HashMap<&'parse str, String>, targets: HashMap<&'parse str, String>,
@ -47,15 +48,15 @@ impl<'orig, 'parse> Registry<'orig, 'parse> {
/// ///
/// This needs to be incremented to be 1-indexed for render. /// This needs to be incremented to be 1-indexed for render.
pub(crate) async fn get_footnote_reference_id<'orig, 'parse>( pub(crate) async fn get_footnote_reference_id<'orig, 'parse>(
registry: RefRegistry<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
label: Option<&'parse str>, label: Option<&'parse str>,
definition: &'orig Vec<Object<'parse>>, definition: &'orig Vec<Object<'parse>>,
) -> Result<(usize, usize), CustomError> { ) -> Result<(usize, usize), CustomError> {
if let None = label { if let None = label {
// If it has no label then it must always get a new ID. // If it has no label then it must always get a new ID.
let contents = convert_reference_contents(registry.clone(), definition).await?; let contents = convert_reference_contents(intermediate_context.clone(), definition).await?;
let pos = { let pos = {
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
registry.footnote_ids.push((None, contents)); registry.footnote_ids.push((None, contents));
registry.footnote_ids.len() - 1 registry.footnote_ids.len() - 1
}; };
@ -63,8 +64,8 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>(
} }
let reference_count = if let Some(label) = label { let reference_count = if let Some(label) = label {
promote_footnote_definition(registry.clone(), label).await?; promote_footnote_definition(intermediate_context.clone(), label).await?;
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
let reference_count = registry let reference_count = registry
.footnote_reference_counts .footnote_reference_counts
.entry(label) .entry(label)
@ -75,7 +76,8 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>(
0 0
}; };
let existing_index = registry let existing_index = intermediate_context
.registry
.lock() .lock()
.unwrap() .unwrap()
.footnote_ids .footnote_ids
@ -83,8 +85,9 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>(
.position(|(id, _definition)| *id == label); .position(|(id, _definition)| *id == label);
if let Some(existing_id) = existing_index { if let Some(existing_id) = existing_index {
if !definition.is_empty() { if !definition.is_empty() {
let contents = convert_reference_contents(registry.clone(), definition).await?; let contents =
let mut registry = registry.lock().unwrap(); convert_reference_contents(intermediate_context.clone(), definition).await?;
let mut registry = intermediate_context.registry.lock().unwrap();
let entry = registry let entry = registry
.footnote_ids .footnote_ids
.get_mut(existing_id) .get_mut(existing_id)
@ -94,13 +97,13 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>(
Ok((existing_id, reference_count)) Ok((existing_id, reference_count))
} else { } else {
let existing_id = { let existing_id = {
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
registry.footnote_ids.push((label, Vec::new())); registry.footnote_ids.push((label, Vec::new()));
registry.footnote_ids.len() - 1 registry.footnote_ids.len() - 1
}; };
let contents = convert_reference_contents(registry.clone(), definition).await?; let contents = convert_reference_contents(intermediate_context.clone(), definition).await?;
{ {
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
let entry = registry let entry = registry
.footnote_ids .footnote_ids
.get_mut(existing_id) .get_mut(existing_id)
@ -113,24 +116,24 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>(
/// Update the definition to a footnote but do not mark it as referenced. /// Update the definition to a footnote but do not mark it as referenced.
pub(crate) async fn register_footnote_definition<'orig, 'parse>( pub(crate) async fn register_footnote_definition<'orig, 'parse>(
registry: RefRegistry<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
label: &'parse str, label: &'parse str,
definition: &'orig Vec<Element<'parse>>, definition: &'orig Vec<Element<'parse>>,
) -> Result<(), CustomError> { ) -> Result<(), CustomError> {
let has_existing: bool = { let has_existing: bool = {
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
registry registry
.footnote_ids .footnote_ids
.iter_mut() .iter_mut()
.any(|(id, _definition)| *id == Some(label)) .any(|(id, _definition)| *id == Some(label))
}; };
if !has_existing { if !has_existing {
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
registry.on_deck_footnote_ids.insert(label, definition); registry.on_deck_footnote_ids.insert(label, definition);
return Ok(()); return Ok(());
} }
let contents = convert_definition_contents(registry.clone(), definition).await?; let contents = convert_definition_contents(intermediate_context.clone(), definition).await?;
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
if let Some((_existing_id, existing_definition)) = registry if let Some((_existing_id, existing_definition)) = registry
.footnote_ids .footnote_ids
.iter_mut() .iter_mut()
@ -142,13 +145,13 @@ pub(crate) async fn register_footnote_definition<'orig, 'parse>(
} }
async fn convert_reference_contents<'orig, 'parse>( async fn convert_reference_contents<'orig, 'parse>(
registry: RefRegistry<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
contents: &'orig Vec<Object<'parse>>, contents: &'orig Vec<Object<'parse>>,
) -> Result<Vec<IAstNode>, CustomError> { ) -> Result<Vec<IAstNode>, CustomError> {
let contents = { let contents = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in contents.iter() { for obj in contents.iter() {
ret.push(obj.into_ast_node(registry.clone()).await?); ret.push(obj.into_ast_node(intermediate_context.clone()).await?);
} }
ret ret
}; };
@ -157,13 +160,13 @@ async fn convert_reference_contents<'orig, 'parse>(
} }
async fn convert_definition_contents<'orig, 'parse>( async fn convert_definition_contents<'orig, 'parse>(
registry: RefRegistry<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
contents: &'orig Vec<Element<'parse>>, contents: &'orig Vec<Element<'parse>>,
) -> Result<Vec<IAstNode>, CustomError> { ) -> Result<Vec<IAstNode>, CustomError> {
let contents = { let contents = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in contents.iter() { for obj in contents.iter() {
ret.push(obj.into_ast_node(registry.clone()).await?); ret.push(obj.into_ast_node(intermediate_context.clone()).await?);
} }
ret ret
}; };
@ -173,23 +176,23 @@ async fn convert_definition_contents<'orig, 'parse>(
/// Take a footnote definition that has not yet received a reference and move it into the active footnotes. /// Take a footnote definition that has not yet received a reference and move it into the active footnotes.
pub(crate) async fn promote_footnote_definition<'orig, 'parse>( pub(crate) async fn promote_footnote_definition<'orig, 'parse>(
registry: RefRegistry<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
label: &'parse str, label: &'parse str,
) -> Result<(), CustomError> { ) -> Result<(), CustomError> {
let definition = { let definition = {
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
let definition = registry.on_deck_footnote_ids.remove(label); let definition = registry.on_deck_footnote_ids.remove(label);
definition definition
}; };
if let Some(elements) = definition { if let Some(elements) = definition {
let existing_id = { let existing_id = {
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
registry.footnote_ids.push((Some(label), Vec::new())); registry.footnote_ids.push((Some(label), Vec::new()));
registry.footnote_ids.len() - 1 registry.footnote_ids.len() - 1
}; };
let contents = convert_definition_contents(registry.clone(), elements).await?; let contents = convert_definition_contents(intermediate_context.clone(), elements).await?;
{ {
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
let entry = registry let entry = registry
.footnote_ids .footnote_ids
.get_mut(existing_id) .get_mut(existing_id)

View File

@ -13,12 +13,12 @@ intermediate!(
IRegularLink, IRegularLink,
&'orig organic::types::RegularLink<'parse>, &'orig organic::types::RegularLink<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IObject::new(registry.clone(), obj).await?); ret.push(IObject::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -12,12 +12,12 @@ intermediate!(
ISection, ISection,
&'orig organic::types::Section<'parse>, &'orig organic::types::Section<'parse>,
original, original,
registry, intermediate_context,
{ {
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(intermediate_context.clone(), elem).await?);
} }
ret ret
}; };

View File

@ -12,7 +12,7 @@ intermediate!(
ISrcBlock, ISrcBlock,
&'orig organic::types::SrcBlock<'parse>, &'orig organic::types::SrcBlock<'parse>,
original, original,
_registry, _intermediate_context,
{ {
let source_code = original.get_value(); let source_code = original.get_value();
let prefix_content_pairs: Vec<_> = source_code let prefix_content_pairs: Vec<_> = source_code

View File

@ -12,12 +12,12 @@ intermediate!(
IStrikeThrough, IStrikeThrough,
&'orig organic::types::StrikeThrough<'parse>, &'orig organic::types::StrikeThrough<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IObject::new(registry.clone(), obj).await?); ret.push(IObject::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -12,12 +12,12 @@ intermediate!(
ITable, ITable,
&'orig organic::types::Table<'parse>, &'orig organic::types::Table<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(ITableRow::new(registry.clone(), obj).await?); ret.push(ITableRow::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -12,12 +12,12 @@ intermediate!(
ITableCell, ITableCell,
&'orig organic::types::TableCell<'parse>, &'orig organic::types::TableCell<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IObject::new(registry.clone(), obj).await?); ret.push(IObject::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -11,12 +11,12 @@ intermediate!(
ITableRow, ITableRow,
&'orig organic::types::TableRow<'parse>, &'orig organic::types::TableRow<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(ITableCell::new(registry.clone(), obj).await?); ret.push(ITableCell::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -12,9 +12,9 @@ intermediate!(
ITarget, ITarget,
&'orig organic::types::Target<'parse>, &'orig organic::types::Target<'parse>,
original, original,
registry, intermediate_context,
{ {
let mut registry = registry.lock().unwrap(); let mut registry = intermediate_context.registry.lock().unwrap();
let id = registry.get_target(original.value); let id = registry.get_target(original.value);
Ok(ITarget { Ok(ITarget {
id: id.clone(), id: id.clone(),

View File

@ -12,12 +12,12 @@ intermediate!(
IUnderline, IUnderline,
&'orig organic::types::Underline<'parse>, &'orig organic::types::Underline<'parse>,
original, original,
registry, intermediate_context,
{ {
let children = { let children = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in original.children.iter() { for obj in original.children.iter() {
ret.push(IObject::new(registry.clone(), obj).await?); ret.push(IObject::new(intermediate_context.clone(), obj).await?);
} }
ret ret
}; };

View File

@ -11,7 +11,7 @@ intermediate!(
IVerbatim, IVerbatim,
&'orig organic::types::Verbatim<'parse>, &'orig organic::types::Verbatim<'parse>,
original, original,
_registry, _intermediate_context,
{ {
Ok(IVerbatim { Ok(IVerbatim {
// TODO: Should this coalesce whitespace like PlainText? // TODO: Should this coalesce whitespace like PlainText?