diff --git a/src/duster/parser.rs b/src/duster/parser.rs index f38a846..b0c8b4d 100644 --- a/src/duster/parser.rs +++ b/src/duster/parser.rs @@ -144,11 +144,14 @@ fn reference(i: &str) -> IResult<&str, Reference> { } fn section(i: &str) -> IResult<&str, Section> { - let (i, opening_name) = delimited(tag("{#"), path, tag("}"))(i)?; - let (i, inner) = opt(block)(i)?; - let (i, _closing_name) = verify(delimited(tag("{/"), path, tag("}")), |name: &Path| { - name == &opening_name - })(i)?; + let (i, (opening_name, inner, _closing_name)) = verify( + tuple(( + delimited(tag("{#"), path, tag("}")), + opt(block), + delimited(tag("{/"), path, tag("}")), + )), + |(open, inn, close)| open == close, + )(i)?; Ok(( i, @@ -304,7 +307,7 @@ mod tests { fn test_section_mismatched_paths() { assert_eq!( super::section("{#foo.bar}{/baz}"), - Err(Error(("{/baz}", ErrorKind::Verify))) + Err(Error(("{#foo.bar}{/baz}", ErrorKind::Verify))) ); } @@ -322,11 +325,6 @@ mod tests { } )) ); - - assert_eq!( - super::section("{#foo.bar}{/baz}"), - Err(Error(("{/baz}", ErrorKind::Verify))) - ); } #[test]