Handle empty statistics cookies.
This commit is contained in:
parent
d79035e14d
commit
0105b49d0d
@ -1,5 +1,6 @@
|
|||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
|
use nom::combinator::opt;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
@ -27,8 +28,11 @@ pub fn percent_statistics_cookie<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, StatisticsCookie<'s>> {
|
) -> Res<OrgSource<'s>, StatisticsCookie<'s>> {
|
||||||
let (remaining, _) =
|
let (remaining, _) = recognize(tuple((
|
||||||
recognize(tuple((tag("["), nom::character::complete::u64, tag("%]"))))(input)?;
|
tag("["),
|
||||||
|
opt(nom::character::complete::u64),
|
||||||
|
tag("%]"),
|
||||||
|
)))(input)?;
|
||||||
let (remaining, _trailing_whitespace) =
|
let (remaining, _trailing_whitespace) =
|
||||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
@ -47,9 +51,9 @@ pub fn fraction_statistics_cookie<'b, 'g, 'r, 's>(
|
|||||||
) -> Res<OrgSource<'s>, StatisticsCookie<'s>> {
|
) -> Res<OrgSource<'s>, StatisticsCookie<'s>> {
|
||||||
let (remaining, _) = recognize(tuple((
|
let (remaining, _) = recognize(tuple((
|
||||||
tag("["),
|
tag("["),
|
||||||
nom::character::complete::u64,
|
opt(nom::character::complete::u64),
|
||||||
tag("/"),
|
tag("/"),
|
||||||
nom::character::complete::u64,
|
opt(nom::character::complete::u64),
|
||||||
tag("]"),
|
tag("]"),
|
||||||
)))(input)?;
|
)))(input)?;
|
||||||
let (remaining, _trailing_whitespace) =
|
let (remaining, _trailing_whitespace) =
|
||||||
|
Loading…
Reference in New Issue
Block a user