Implement the parser for inline babel calls.

This commit is contained in:
Tom Alexander
2023-07-21 21:38:32 -04:00
parent 2773b35438
commit 45b01012b3
4 changed files with 186 additions and 7 deletions

View File

@@ -168,6 +168,19 @@ pub enum ContextElement<'r, 's> {
/// unbalanced brackets can be detected in the middle of an
/// object.
CitationBracket(CitationBracket<'s>),
/// Stores the current bracket or parenthesis depth inside an inline babel call.
///
/// Inside an inline babel call the headers must have balanced
/// parentheses () and the arguments must have balanced brackets
/// [], so this stores the amount of opening brackets subtracted
/// by the amount of closing brackets within the definition must
/// equal zero.
///
/// A reference to the position in the string is also included so
/// unbalanced brackets can be detected in the middle of an
/// object.
BabelHeaderBracket(BabelHeaderBracket<'s>),
}
pub struct ExitMatcherNode<'r> {
@@ -187,6 +200,12 @@ pub struct CitationBracket<'s> {
pub depth: usize,
}
#[derive(Debug)]
pub struct BabelHeaderBracket<'s> {
pub position: &'s str,
pub depth: usize,
}
impl<'r> std::fmt::Debug for ExitMatcherNode<'r> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut formatter = f.debug_struct("ExitMatcherNode");