Allow spaces before closing braces on tags without parameters.

Previously I incorrectly only supported spaces before closing braces on tags with parameters. This patch expands that behavior to all tags.
master
Tom Alexander 4 years ago
parent 44d54c86d2
commit 69fa266692
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -358,7 +358,10 @@ fn key_to_path<'a>(i: &'a str) -> IResult<&str, Path<'a>> {
fn postitive_integer_literal(i: &str) -> IResult<&str, u64> { fn postitive_integer_literal(i: &str) -> IResult<&str, u64> {
map( map(
verify( verify(
map(digit1, |number_string: &str| number_string.parse::<u64>()), map(
recognize(tuple((opt(tag("+")), digit1))),
|number_string: &str| number_string.parse::<u64>(),
),
|parse_result| parse_result.is_ok(), |parse_result| parse_result.is_ok(),
), ),
|parsed_number| parsed_number.unwrap(), |parsed_number| parsed_number.unwrap(),
@ -434,7 +437,11 @@ fn key_value_pair(i: &str) -> IResult<&str, KVPair> {
/// Display a value from the context /// Display a value from the context
fn reference(i: &str) -> IResult<&str, Reference> { fn reference(i: &str) -> IResult<&str, Reference> {
let (remaining, (p, filters)) = delimited(tag("{"), tuple((path, many0(filter))), tag("}"))(i)?; let (remaining, (p, filters)) = delimited(
tag("{"),
tuple((path, many0(filter))),
preceded(space0, tag("}")),
)(i)?;
Ok(( Ok((
remaining, remaining,
Reference { Reference {
@ -484,12 +491,8 @@ where
preceded(tag(open_matcher), name_matcher), preceded(tag(open_matcher), name_matcher),
opt(preceded(tag(":"), path)), opt(preceded(tag(":"), path)),
terminated( terminated(
opt(delimited( opt(preceded(space1, separated_list1(space1, key_value_pair))),
space1, preceded(space0, tag("}")),
separated_list1(space1, key_value_pair),
space0,
)),
tag("}"),
), ),
opt(body), opt(body),
opt(preceded(tag("{:else}"), opt(body))), opt(preceded(tag("{:else}"), opt(body))),
@ -525,12 +528,8 @@ where
preceded(tag(open_matcher), name_matcher), preceded(tag(open_matcher), name_matcher),
opt(preceded(tag(":"), path)), opt(preceded(tag(":"), path)),
terminated( terminated(
opt(delimited( opt(preceded(space1, separated_list1(space1, key_value_pair))),
space1, preceded(space0, tag("}")),
separated_list1(space1, key_value_pair),
space0,
)),
tag("}"),
), ),
opt(body), opt(body),
delimited(tag("{/"), name_matcher, tag("}")), delimited(tag("{/"), name_matcher, tag("}")),
@ -564,13 +563,9 @@ where
tuple(( tuple((
name_matcher, name_matcher,
opt(preceded(tag(":"), path)), opt(preceded(tag(":"), path)),
opt(delimited( opt(preceded(space1, separated_list1(space1, key_value_pair))),
space1,
separated_list1(space1, key_value_pair),
space0,
)),
)), )),
tag("/}"), preceded(space0, tag("/}")),
)(i)?; )(i)?;
Ok(( Ok((
@ -595,13 +590,9 @@ fn partial_with_plain_tag<'a>(
tuple(( tuple((
key, key,
opt(preceded(tag(":"), path)), opt(preceded(tag(":"), path)),
opt(delimited( opt(preceded(space1, separated_list1(space1, key_value_pair))),
space1,
separated_list1(space1, key_value_pair),
space0,
)),
)), )),
tag("/}"), preceded(space0, tag("/}")),
)(i)?; )(i)?;
Ok(( Ok((
@ -633,13 +624,9 @@ fn partial_with_quoted_tag<'a>(
tuple(( tuple((
template_string_rvalue, template_string_rvalue,
opt(preceded(tag(":"), path)), opt(preceded(tag(":"), path)),
opt(delimited( opt(preceded(space1, separated_list1(space1, key_value_pair))),
space1,
separated_list1(space1, key_value_pair),
space0,
)),
)), )),
tag("/}"), preceded(space0, tag("/}")),
)(i)?; )(i)?;
Ok(( Ok((

Loading…
Cancel
Save