Compare commits

...

2 Commits

Author SHA1 Message Date
Tom Alexander
9bdec391f1
Do not capture trailing whitespace on the final macro arg.
Some checks failed
rust-build Build rust-build has succeeded
rust-foreign-document-test Build rust-foreign-document-test has failed
rust-test Build rust-test has succeeded
2023-10-08 16:39:22 -04:00
Tom Alexander
b9ead09dde
Add test showing we are not handling trailing whitespace in macro args properly. 2023-10-08 16:34:28 -04:00
2 changed files with 13 additions and 1 deletions

View File

@ -2,3 +2,9 @@
{{{foo(bar
baz)}}}
{{{foo(foo )}}}
{{{foo(foo , bar )}}}
{{{foo(foo , bar , baz )}}}

View File

@ -1,11 +1,13 @@
use nom::bytes::complete::tag;
use nom::character::complete::anychar;
use nom::character::complete::space0;
use nom::combinator::not;
use nom::combinator::opt;
use nom::combinator::peek;
use nom::combinator::verify;
use nom::multi::many0;
use nom::multi::separated_list0;
use nom::sequence::tuple;
use super::org_source::OrgSource;
use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting;
@ -67,7 +69,7 @@ fn org_macro_args<'b, 'g, 'r, 's>(
let (remaining, _) = tag("(")(input)?;
let (remaining, args) =
separated_list0(tag(","), parser_with_context!(org_macro_arg)(context))(remaining)?;
let (remaining, _) = tag(")")(remaining)?;
let (remaining, _) = tuple((space0, tag(")")))(remaining)?;
Ok((remaining, args))
}
@ -82,6 +84,10 @@ fn org_macro_arg<'b, 'g, 'r, 's>(
loop {
not(parser_with_context!(exit_matcher_parser)(context))(remaining)?;
not(peek(tag("}}}")))(remaining)?;
if peek(tuple((space0::<OrgSource<'_>, CustomError<_>>, tag(")"))))(remaining).is_ok() {
break;
}
let (new_remaining, next_char) = anychar(remaining)?;
if escaping {
remaining = new_remaining;