aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src
diff options
context:
space:
mode:
authorLibravatar vallentin <mail@vallentin.dev>2021-01-05 14:50:13 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-01-05 16:17:14 +0100
commitc1f627d4dd99e945c45f44c0a470564398bd4573 (patch)
tree1103b78d83547815c36c2142b4b32f3b906be05f /askama_shared/src
parente84e958a73d623a38b063915a90ba6371326a350 (diff)
downloadaskama-c1f627d4dd99e945c45f44c0a470564398bd4573.tar.gz
askama-c1f627d4dd99e945c45f44c0a470564398bd4573.tar.bz2
askama-c1f627d4dd99e945c45f44c0a470564398bd4573.zip
Fixed parsing floats
Diffstat (limited to '')
-rw-r--r--askama_shared/src/parser.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs
index e13a54a..72c6b82 100644
--- a/askama_shared/src/parser.rs
+++ b/askama_shared/src/parser.rs
@@ -1,7 +1,7 @@
use nom::branch::alt;
use nom::bytes::complete::{escaped, is_not, tag, take_until};
use nom::character::complete::{anychar, char, digit1};
-use nom::combinator::{complete, map, opt, value};
+use nom::combinator::{complete, map, opt, recognize, value};
use nom::error::{Error, ParseError};
use nom::multi::{many0, many1, separated_list0, separated_list1};
use nom::sequence::{delimited, pair, tuple};
@@ -231,7 +231,9 @@ fn expr_bool_lit(i: &[u8]) -> IResult<&[u8], Expr> {
}
fn num_lit(i: &[u8]) -> IResult<&[u8], &str> {
- map(digit1, |s| str::from_utf8(s).unwrap())(i)
+ map(recognize(pair(digit1, opt(pair(tag("."), digit1)))), |s| {
+ str::from_utf8(s).unwrap()
+ })(i)
}
fn expr_num_lit(i: &[u8]) -> IResult<&[u8], Expr> {