Fix counting brackets in inline source block.
This commit is contained in:
parent
e8979513aa
commit
0b41e12424
2
org_mode_samples/inline_source_block/simple.org
Normal file
2
org_mode_samples/inline_source_block/simple.org
Normal file
@ -0,0 +1,2 @@
|
||||
before src_foo{ipsum} after
|
||||
src_bar[lorem]{ipsum}
|
@ -1422,7 +1422,7 @@ fn compare_inline_source_block<'s>(
|
||||
rust: &'s InlineSourceBlock<'s>,
|
||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
[cite/a/b-_/foo:globalprefix;keyprefix @foo keysuffix;globalsuffix]
|
||||
before src_foo{ipsum} after
|
||||
src_bar[lorem]{ipsum}
|
||||
|
Loading…
Reference in New Issue
Block a user