From 90a47b7b49cdb12b383f4fa9459c2efc15133823 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 24 Apr 2023 17:16:07 -0400 Subject: [PATCH] Exit text markup if the parent exit matcher is triggering. --- src/parser/text_markup.rs | 25 +++++++++++++++++-------- toy_language.txt | 4 +++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/parser/text_markup.rs b/src/parser/text_markup.rs index 3d6181c..a7a9497 100644 --- a/src/parser/text_markup.rs +++ b/src/parser/text_markup.rs @@ -12,6 +12,7 @@ use nom::combinator::recognize; use nom::combinator::verify; use nom::multi::many_till; use nom::sequence::terminated; +use tracing::span; use super::Context; use crate::error::CustomError; @@ -131,10 +132,14 @@ fn _text_markup_object<'r, 's, 'x>( |(children, _exit_contents)| !children.is_empty(), )(remaining)?; - if exit_matcher_parser(context, remaining).is_ok() { - return Err(nom::Err::Error(CustomError::MyError(MyError( - "Parent exit matcher is triggering.", - )))); + { + let span = span!(tracing::Level::DEBUG, "Checking parent exit."); + let _enter = span.enter(); + if exit_matcher_parser(context, remaining).is_ok() { + return Err(nom::Err::Error(CustomError::MyError(MyError( + "Parent exit matcher is triggering.", + )))); + } } // TODO: Sometimes its plain text, not objects @@ -174,10 +179,14 @@ fn _text_markup_string<'r, 's, 'x>( |(children, _exit_contents)| !children.is_empty(), ))(remaining)?; - if exit_matcher_parser(context, remaining).is_ok() { - return Err(nom::Err::Error(CustomError::MyError(MyError( - "Parent exit matcher is triggering.", - )))); + { + let span = span!(tracing::Level::DEBUG, "Checking parent exit."); + let _enter = span.enter(); + if exit_matcher_parser(context, remaining).is_ok() { + return Err(nom::Err::Error(CustomError::MyError(MyError( + "Parent exit matcher is triggering.", + )))); + } } // TODO: Sometimes its plain text, not objects diff --git a/toy_language.txt b/toy_language.txt index b9372be..64ee871 100644 --- a/toy_language.txt +++ b/toy_language.txt @@ -1 +1,3 @@ -*nesting *bold entrances* and* exits +foo *bar /baz *lorem* ipsum/ dolar* alpha + +foo *bar /baz _lorem_ ipsum/ dolar* alpha