Implement parser for inline source blocks.

This commit is contained in:
Tom Alexander
2023-07-21 22:51:19 -04:00
parent e0d2bb8213
commit e8979513aa
3 changed files with 187 additions and 5 deletions

View File

@@ -181,6 +181,19 @@ pub enum ContextElement<'r, 's> {
/// unbalanced brackets can be detected in the middle of an
/// object.
BabelHeaderBracket(BabelHeaderBracket<'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.
InlineSourceBlockBracket(InlineSourceBlockBracket<'s>),
}
pub struct ExitMatcherNode<'r> {
@@ -206,6 +219,12 @@ pub struct BabelHeaderBracket<'s> {
pub depth: usize,
}
#[derive(Debug)]
pub struct InlineSourceBlockBracket<'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");