Create structure for line breaks.

This commit is contained in:
Tom Alexander
2023-07-21 23:48:37 -04:00
parent 6b82214ec3
commit 4d114206ef
5 changed files with 54 additions and 0 deletions

13
src/parser/line_break.rs Normal file
View File

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

View File

@@ -25,6 +25,7 @@ mod latex_environment;
mod latex_fragment;
mod lesser_block;
mod lesser_element;
mod line_break;
mod list;
mod object;
mod object_parser;
@@ -87,6 +88,7 @@ pub use object::InlineBabelCall;
pub use object::InlineSourceBlock;
pub use object::Italic;
pub use object::LatexFragment;
pub use object::LineBreak;
pub use object::Object;
pub use object::OrgMacro;
pub use object::PlainLink;

View File

@@ -23,6 +23,7 @@ pub enum Object<'s> {
CitationReference(CitationReference<'s>),
InlineBabelCall(InlineBabelCall<'s>),
InlineSourceBlock(InlineSourceBlock<'s>),
LineBreak(LineBreak<'s>),
}
#[derive(Debug, PartialEq)]
@@ -149,6 +150,11 @@ pub struct InlineSourceBlock<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
pub struct LineBreak<'s> {
pub source: &'s str,
}
impl<'s> Source<'s> for Object<'s> {
fn get_source(&'s self) -> &'s str {
match self {
@@ -173,6 +179,7 @@ impl<'s> Source<'s> for Object<'s> {
Object::CitationReference(obj) => obj.source,
Object::InlineBabelCall(obj) => obj.source,
Object::InlineSourceBlock(obj) => obj.source,
Object::LineBreak(obj) => obj.source,
}
}
}
@@ -296,3 +303,9 @@ impl<'s> Source<'s> for InlineSourceBlock<'s> {
self.source
}
}
impl<'s> Source<'s> for LineBreak<'s> {
fn get_source(&'s self) -> &'s str {
self.source
}
}

View File

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