Introduce CommaWithSpace

This allows us to support stroke-dasharray the same way as comma-separated
values.
This commit is contained in:
Anthony Ramine 2017-06-27 11:06:24 +02:00
parent 17875b8a81
commit c03f5f19ab
4 changed files with 39 additions and 23 deletions

View file

@ -172,22 +172,6 @@ where
}
}
/// Parse a non-empty space-separated or comma-separated list of objects parsed by parse_one
pub fn parse_space_or_comma_separated<'i, 't, F, T>(input: &mut Parser<'i, 't>, mut parse_one: F)
-> Result<Vec<T>, ParseError<'i>>
where F: for<'ii, 'tt> FnMut(&mut Parser<'ii, 'tt>) -> Result<T, ParseError<'ii>> {
let first = parse_one(input)?;
let mut vec = vec![first];
loop {
let _ = input.try(|i| i.expect_comma());
if let Ok(val) = input.try(|i| parse_one(i)) {
vec.push(val)
} else {
break
}
}
Ok(vec)
}
impl Parse for UnicodeRange {
fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<Self, ParseError<'i>> {