Truncate keywords (some of them probably shouldn't be keywords)
This commit is contained in:
parent
7e5214d629
commit
8756adaaaf
@ -215,38 +215,38 @@ impl Display for Op {
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum Keyword {
|
||||
Important,
|
||||
Infinity,
|
||||
NaN,
|
||||
Auto,
|
||||
Inherit,
|
||||
Initial,
|
||||
Unset,
|
||||
True,
|
||||
False,
|
||||
Not,
|
||||
And,
|
||||
Or,
|
||||
Null,
|
||||
In,
|
||||
// Infinity,
|
||||
// NaN,
|
||||
// Auto,
|
||||
// Inherit,
|
||||
// Initial,
|
||||
// Unset,
|
||||
// Not,
|
||||
// And,
|
||||
// Or,
|
||||
// In,
|
||||
}
|
||||
|
||||
impl Display for Keyword {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Important => write!(f, "!important"),
|
||||
Self::Infinity => write!(f, "Infinity"),
|
||||
Self::NaN => write!(f, "NaN"),
|
||||
Self::Auto => write!(f, "auto"),
|
||||
Self::Inherit => write!(f, "inherit"),
|
||||
Self::Initial => write!(f, "initial"),
|
||||
Self::Unset => write!(f, "unset"),
|
||||
Self::True => write!(f, "true"),
|
||||
Self::False => write!(f, "false"),
|
||||
Self::Not => write!(f, "not"),
|
||||
Self::And => write!(f, "and"),
|
||||
Self::Or => write!(f, "or"),
|
||||
Self::Null => write!(f, "null"),
|
||||
Self::In => write!(f, "in"),
|
||||
// Self::Infinity => write!(f, "Infinity"),
|
||||
// Self::NaN => write!(f, "NaN"),
|
||||
// Self::Auto => write!(f, "auto"),
|
||||
// Self::Inherit => write!(f, "inherit"),
|
||||
// Self::Initial => write!(f, "initial"),
|
||||
// Self::Unset => write!(f, "unset"),
|
||||
// Self::Not => write!(f, "not"),
|
||||
// Self::And => write!(f, "and"),
|
||||
// Self::Or => write!(f, "or"),
|
||||
// Self::In => write!(f, "in"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -255,19 +255,19 @@ impl Into<&'static str> for Keyword {
|
||||
fn into(self) -> &'static str {
|
||||
match self {
|
||||
Self::Important => "!important",
|
||||
Self::Infinity => "Infinity",
|
||||
Self::NaN => "NaN",
|
||||
Self::Auto => "auto",
|
||||
Self::Inherit => "inherit",
|
||||
Self::Initial => "initial",
|
||||
Self::Unset => "unset",
|
||||
Self::True => "true",
|
||||
Self::False => "false",
|
||||
Self::Not => "not",
|
||||
Self::And => "and",
|
||||
Self::Or => "or",
|
||||
Self::Null => "null",
|
||||
Self::In => "in",
|
||||
// Self::Infinity => "Infinity",
|
||||
// Self::NaN => "NaN",
|
||||
// Self::Auto => "auto",
|
||||
// Self::Inherit => "inherit",
|
||||
// Self::Initial => "initial",
|
||||
// Self::Unset => "unset",
|
||||
// Self::Not => "not",
|
||||
// Self::And => "and",
|
||||
// Self::Or => "or",
|
||||
// Self::In => "in",
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,19 +279,19 @@ impl TryFrom<&str> for Keyword {
|
||||
// todo: case insensitive?
|
||||
match kw {
|
||||
"important" => Ok(Self::Important),
|
||||
"infinity" => Ok(Self::Infinity),
|
||||
"nan" => Ok(Self::NaN),
|
||||
"auto" => Ok(Self::Auto),
|
||||
"inherit" => Ok(Self::Inherit),
|
||||
"initial" => Ok(Self::Initial),
|
||||
"unset" => Ok(Self::Unset),
|
||||
"true" => Ok(Self::True),
|
||||
"false" => Ok(Self::False),
|
||||
"not" => Ok(Self::Not),
|
||||
"and" => Ok(Self::And),
|
||||
"or" => Ok(Self::Or),
|
||||
"null" => Ok(Self::Null),
|
||||
"in" => Ok(Self::In),
|
||||
// "infinity" => Ok(Self::Infinity),
|
||||
// "nan" => Ok(Self::NaN),
|
||||
// "auto" => Ok(Self::Auto),
|
||||
// "inherit" => Ok(Self::Inherit),
|
||||
// "initial" => Ok(Self::Initial),
|
||||
// "unset" => Ok(Self::Unset),
|
||||
// "not" => Ok(Self::Not),
|
||||
// "and" => Ok(Self::And),
|
||||
// "or" => Ok(Self::Or),
|
||||
// "in" => Ok(Self::In),
|
||||
_ => Err("invalid keyword"),
|
||||
}
|
||||
}
|
||||
|
@ -653,6 +653,9 @@ mod test_values {
|
||||
test!(comma_list_number, "a {\n color: 1, 2, 3;\n}\n");
|
||||
test!(space_list_number, "a {\n color: 1 2 3;\n}\n");
|
||||
test!(comma_space_list_number, "a {\n color: 1 1, 2 2, 3 3;\n}\n");
|
||||
test!(preserves_keyword_true, "a {\n color: true;\n}\n");
|
||||
test!(preserves_keyword_false, "a {\n color: false;\n}\n");
|
||||
test!(preserves_keyword_null, "a {\n color: null;\n}\n");
|
||||
test!(
|
||||
whitespace_space_list_number,
|
||||
"a {\n color: 1 2 3 ;\n}\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user