Handle nesting of brackets.
All checks were successful
rust-build Build rust-build has succeeded
rust-test Build rust-test has succeeded
rust-foreign-document-test Build rust-foreign-document-test has succeeded

This commit is contained in:
Tom Alexander 2023-10-05 19:49:07 -04:00
parent 885fefd060
commit fa97124186
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -113,17 +113,14 @@ fn babel_call_call<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn inside_header<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
let (remaining, _) = tag("[")(input)?;
let contents_start = remaining;
let (remaining, contents) = opt(recognize(many_till(
anychar,
alt((
peek(recognize(one_of("]"))),
recognize(tuple((space0, org_line_ending))),
)),
)))(remaining)?;
let (remaining, _) = tag("]")(remaining)?;
let (remaining, contents) = balanced_bracket(
|i| tag("[")(i),
|i| peek(tag("]"))(i),
|i| recognize(tuple((space0, org_line_ending)))(i),
|i| tag("]")(i),
|s| s.get_bracket_depth(),
)(input)?;
let (contents_start, _) = tag("[")(input)?;
Ok((remaining, contents.unwrap_or(contents_start.take(0))))
}
@ -136,30 +133,6 @@ fn arguments<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, Option<OrgSource<'s
|i| tag(")")(i),
|s| s.get_parenthesis_depth(),
)(input)
// impl_balanced_bracket(
// input,
// |i| tag("(")(i),
// |i| peek(tag(")"))(i),
// |i| recognize(tuple((space0, org_line_ending)))(i),
// |i| tag(")")(i),
// |s| s.get_parenthesis_depth(),
// )
// let (remaining, _) = tag("(")(input)?;
// let (remaining, contents) = opt(verify(
// recognize(many_till(
// anychar,
// alt((
// peek(recognize(one_of(")"))),
// recognize(tuple((space0, org_line_ending))),
// )),
// )),
// |s| s.len() > 0,
// ))(remaining)?;
// let (remaining, _) = tag(")")(remaining)?;
// Ok((remaining, contents))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]