From c1f627d4dd99e945c45f44c0a470564398bd4573 Mon Sep 17 00:00:00 2001 From: vallentin Date: Tue, 5 Jan 2021 14:50:13 +0100 Subject: Fixed parsing floats --- askama_shared/src/parser.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'askama_shared/src') 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> { -- cgit