Make predefined counter style names ASCII-lowercase.

This commit is contained in:
Simon Sapin 2017-04-24 10:49:13 +02:00
parent e7a2a98d8a
commit 82c04113d0
3 changed files with 117 additions and 1 deletions

View file

@ -22,7 +22,28 @@ use values::CustomIdent;
/// Parse the prelude of an @counter-style rule
pub fn parse_counter_style_name(input: &mut Parser) -> Result<CustomIdent, ()> {
CustomIdent::from_ident(input.expect_ident()?, &["decimal", "none"])
macro_rules! predefined {
($($name: expr,)+) => {
{
ascii_case_insensitive_phf_map! {
// FIXME: use static atoms https://github.com/rust-lang/rust/issues/33156
predefined -> &'static str = {
$(
$name => $name,
)+
}
}
let ident = input.expect_ident()?;
if let Some(&lower_cased) = predefined(&ident) {
Ok(CustomIdent(Atom::from(lower_cased)))
} else {
CustomIdent::from_ident(ident, &["decimal", "none"])
}
}
}
}
include!("predefined.rs")
}
/// Parse the body (inside `{}`) of an @counter-style rule