From 5463ed2cdfb35b319009f88b945dff2f7aa7dad3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 6 Apr 2020 21:03:03 -0400 Subject: [PATCH] Added surrounding quotes --- src/parser/parser.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/parser/parser.rs b/src/parser/parser.rs index 6c6d4a7..68d0778 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -328,8 +328,12 @@ pub fn template(i: &str) -> IResult<&str, Template> { Ok((remaining, Template { contents: contents })) } -fn temp_string(i: &str) -> IResult<&str, &str> { - escaped(is_not(r#"\""#), '\\', one_of(r#"\""#))(i) +fn quoted_string(i: &str) -> IResult<&str, &str> { + delimited( + tag(r#"""#), + escaped(is_not(r#"\""#), '\\', one_of(r#"\""#)), + tag(r#"""#), + )(i) } #[cfg(test)] @@ -610,6 +614,6 @@ mod tests { #[test] fn test_temp_string() { - assert_eq!(temp_string(r#"foo\"bar"#), Ok(("", r#"foo\"bar"#))); + assert_eq!(quoted_string(r#""foo\"bar""#), Ok(("", r#"foo\"bar"#))); } }