Create structure for inline babel calls.

This commit is contained in:
Tom Alexander
2023-07-21 19:53:02 -04:00
parent 1e2ea17a9c
commit eef2944307
5 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
use super::Context;
use crate::error::Res;
use crate::parser::util::not_yet_implemented;
use crate::parser::InlineBabelCall;
#[tracing::instrument(ret, level = "debug")]
pub fn inline_babel_call<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, InlineBabelCall<'s>> {
not_yet_implemented()?;
todo!()
}

View File

@@ -18,6 +18,7 @@ mod footnote_reference;
mod greater_block;
mod greater_element;
mod horizontal_rule;
mod inline_babel_call;
mod keyword;
mod latex_environment;
mod latex_fragment;
@@ -81,6 +82,7 @@ pub use object::Code;
pub use object::Entity;
pub use object::ExportSnippet;
pub use object::FootnoteReference;
pub use object::InlineBabelCall;
pub use object::Italic;
pub use object::LatexFragment;
pub use object::Object;

View File

@@ -21,6 +21,7 @@ pub enum Object<'s> {
FootnoteReference(FootnoteReference<'s>),
Citation(Citation<'s>),
CitationReference(CitationReference<'s>),
InlineBabelCall(InlineBabelCall<'s>),
}
#[derive(Debug, PartialEq)]
@@ -137,6 +138,11 @@ pub struct CitationReference<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
pub struct InlineBabelCall<'s> {
pub source: &'s str,
}
impl<'s> Source<'s> for Object<'s> {
fn get_source(&'s self) -> &'s str {
match self {
@@ -159,6 +165,7 @@ impl<'s> Source<'s> for Object<'s> {
Object::FootnoteReference(obj) => obj.source,
Object::Citation(obj) => obj.source,
Object::CitationReference(obj) => obj.source,
Object::InlineBabelCall(obj) => obj.source,
}
}
}
@@ -270,3 +277,9 @@ impl<'s> Source<'s> for CitationReference<'s> {
self.source
}
}
impl<'s> Source<'s> for InlineBabelCall<'s> {
fn get_source(&'s self) -> &'s str {
self.source
}
}

View File

@@ -60,6 +60,7 @@ impl<'r, 's> Token<'r, 's> {
}
Object::Citation(_) => Box::new(std::iter::empty()), // TODO: Iterate over children
Object::CitationReference(_) => Box::new(std::iter::empty()), // TODO: Iterate over children
Object::InlineBabelCall(_) => Box::new(std::iter::empty()), // TODO: Iterate over children
},
Token::Element(elem) => match elem {
Element::Paragraph(inner) => Box::new(inner.children.iter().map(Token::Object)),