diff --git a/org_mode_samples/inline_source_block/simple.org b/org_mode_samples/inline_source_block/simple.org new file mode 100644 index 0000000..1be62f1 --- /dev/null +++ b/org_mode_samples/inline_source_block/simple.org @@ -0,0 +1,2 @@ +before src_foo{ipsum} after +src_bar[lorem]{ipsum} diff --git a/src/compare/diff.rs b/src/compare/diff.rs index ab90531..8d23c7d 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -1422,7 +1422,7 @@ fn compare_inline_source_block<'s>( rust: &'s InlineSourceBlock<'s>, ) -> Result> { let mut this_status = DiffStatus::Good; - let emacs_name = "inline-source-block"; + let emacs_name = "inline-src-block"; if assert_name(emacs, emacs_name).is_err() { this_status = DiffStatus::Bad; } diff --git a/src/parser/inline_source_block.rs b/src/parser/inline_source_block.rs index 229053d..777e3fc 100644 --- a/src/parser/inline_source_block.rs +++ b/src/parser/inline_source_block.rs @@ -8,6 +8,7 @@ use nom::combinator::opt; use nom::combinator::recognize; use nom::combinator::verify; use nom::multi::many_till; +use tracing::span; use super::Context; use crate::error::CustomError; @@ -61,7 +62,7 @@ fn header<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s let parser_context = context .with_additional_node(ContextElement::InlineSourceBlockBracket( InlineSourceBlockBracket { - position: input, + position: remaining, depth: 0, }, )) @@ -115,7 +116,7 @@ fn body<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s st let parser_context = context .with_additional_node(ContextElement::InlineSourceBlockBracket( InlineSourceBlockBracket { - position: input, + position: remaining, depth: 0, }, )) @@ -128,7 +129,15 @@ fn body<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s st anychar, parser_with_context!(exit_matcher_parser)(&parser_context), ))(remaining)?; - let (remaining, _) = tag("}")(remaining)?; + let (remaining, _) = { + let span = span!( + tracing::Level::DEBUG, + "outside end body", + remaining = remaining + ); + let _enter = span.enter(); + tag("}")(remaining)? + }; Ok((remaining, body_contents)) } @@ -152,10 +161,20 @@ fn body_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &' _ => {} } } - if current_depth == 0 { - let close_bracket = tag::<&str, &str, CustomError<&str>>("}")(input); - if close_bracket.is_ok() { - return close_bracket; + { + let span = span!( + tracing::Level::DEBUG, + "inside end body", + remaining = input, + current_depth = current_depth + ); + let _enter = span.enter(); + + if current_depth == 0 { + let close_bracket = tag::<&str, &str, CustomError<&str>>("}")(input); + if close_bracket.is_ok() { + return close_bracket; + } } } diff --git a/toy_language.txt b/toy_language.txt index 8594a8f..1be62f1 100644 --- a/toy_language.txt +++ b/toy_language.txt @@ -1 +1,2 @@ -[cite/a/b-_/foo:globalprefix;keyprefix @foo keysuffix;globalsuffix] +before src_foo{ipsum} after +src_bar[lorem]{ipsum}