Lex and parse named colors
This commit is contained in:
parent
d9339a68b5
commit
76b2685894
@ -1,8 +1,8 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use super::Builtin;
|
use super::Builtin;
|
||||||
use crate::value::Value;
|
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
|
use crate::value::Value;
|
||||||
|
|
||||||
pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
||||||
f.insert(
|
f.insert(
|
||||||
|
@ -23,4 +23,4 @@ macro_rules! decl {
|
|||||||
($f:ident $name:literal, $body:expr) => {
|
($f:ident $name:literal, $body:expr) => {
|
||||||
$f.insert($name.to_owned(), Box::new($body));
|
$f.insert($name.to_owned(), Box::new($body));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -61,4 +61,4 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
|||||||
let value = arg!(args, 0, "value");
|
let value = arg!(args, 0, "value");
|
||||||
Some(Value::Ident(value.to_string(), QuoteKind::None))
|
Some(Value::Ident(value.to_string(), QuoteKind::None))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ use crate::value::Value;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
|
|
||||||
mod color;
|
mod color;
|
||||||
mod list;
|
mod list;
|
||||||
mod map;
|
mod map;
|
||||||
|
481
src/color.rs
481
src/color.rs
@ -1,481 +0,0 @@
|
|||||||
use std::convert::TryFrom;
|
|
||||||
use std::fmt::{self, Display};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
|
||||||
pub enum Color {
|
|
||||||
AliceBlue, // = 0xF0F8FF,
|
|
||||||
AntiqueWhite, // = 0xFAEBD7,
|
|
||||||
Aqua, // = 0x00FFFF,
|
|
||||||
Aquamarine, // = 0x7FFFD4,
|
|
||||||
Azure, // = 0xF0FFFF,
|
|
||||||
Beige, // = 0xF5F5DC,
|
|
||||||
Bisque, // = 0xFFE4C4,
|
|
||||||
Black, // = 0x000000,
|
|
||||||
BlanchedAlmond, // = 0xFFEBCD,
|
|
||||||
Blue, // = 0x0000FF,
|
|
||||||
BlueViolet, // = 0x8A2BE2,
|
|
||||||
Brown, // = 0xA52A2A,
|
|
||||||
BurlyWood, // = 0xDEB887,
|
|
||||||
CadetBlue, // = 0x5F9EA0,
|
|
||||||
Chartreuse, // = 0x7FFF00,
|
|
||||||
Chocolate, // = 0xD2691E,
|
|
||||||
Coral, // = 0xFF7F50,
|
|
||||||
CornflowerBlue, // = 0x6495ED,
|
|
||||||
Cornsilk, // = 0xFFF8DC,
|
|
||||||
Crimson, // = 0xDC143C,
|
|
||||||
Cyan, // = 0x00FFFF
|
|
||||||
DarkBlue, // = 0x00008B,
|
|
||||||
DarkCyan, // = 0x008B8B,
|
|
||||||
DarkGoldenRod, // = 0xB8860B,
|
|
||||||
DarkGray, // = 0xA9A9A9,
|
|
||||||
DarkGrey, // = 0xA9A9A9
|
|
||||||
DarkGreen, // = 0x006400,
|
|
||||||
DarkKhaki, // = 0xBDB76B,
|
|
||||||
DarkMagenta, // = 0x8B008B,
|
|
||||||
DarkOliveGreen, // = 0x556B2F,
|
|
||||||
DarkOrange, // = 0xFF8C00,
|
|
||||||
DarkOrchid, // = 0x9932CC,
|
|
||||||
DarkRed, // = 0x8B0000,
|
|
||||||
DarkSalmon, // = 0xE9967A,
|
|
||||||
DarkSeaGreen, // = 0x8FBC8F,
|
|
||||||
DarkSlateBlue, // = 0x483D8B,
|
|
||||||
DarkSlateGray, // = 0x2F4F4F,
|
|
||||||
DarkSlateGrey, // = 0x2F4F4F
|
|
||||||
DarkTurquoise, // = 0x00CED1,
|
|
||||||
DarkViolet, // = 0x9400D3,
|
|
||||||
DeepPink, // = 0xFF1493,
|
|
||||||
DeepSkyBlue, // = 0x00BFFF,
|
|
||||||
DimGray, // = 0x696969,
|
|
||||||
DimGrey, // = 0x696969
|
|
||||||
DodgerBlue, // = 0x1E90FF,
|
|
||||||
FireBrick, // = 0xB22222,
|
|
||||||
FloralWhite, // = 0xFFFAF0,
|
|
||||||
ForestGreen, // = 0x228B22,
|
|
||||||
Fuchsia, // = 0xFF00FF,
|
|
||||||
Gainsboro, // = 0xDCDCDC,
|
|
||||||
GhostWhite, // = 0xF8F8FF,
|
|
||||||
Gold, // = 0xFFD700,
|
|
||||||
GoldenRod, // = 0xDAA520,
|
|
||||||
Gray, // = 0x808080,
|
|
||||||
Grey, // = 0x808080
|
|
||||||
Green, // = 0x008000,
|
|
||||||
GreenYellow, // = 0xADFF2F,
|
|
||||||
HoneyDew, // = 0xF0FFF0,
|
|
||||||
HotPink, // = 0xFF69B4,
|
|
||||||
IndianRed, // = 0xCD5C5C,
|
|
||||||
Indigo, // = 0x4B0082,
|
|
||||||
Ivory, // = 0xFFFFF0,
|
|
||||||
Khaki, // = 0xF0E68C,
|
|
||||||
Lavender, // = 0xE6E6FA,
|
|
||||||
LavenderBlush, // = 0xFFF0F5,
|
|
||||||
LawnGreen, // = 0x7CFC00,
|
|
||||||
LemonChiffon, // = 0xFFFACD,
|
|
||||||
LightBlue, // = 0xADD8E6,
|
|
||||||
LightCoral, // = 0xF08080,
|
|
||||||
LightCyan, // = 0xE0FFFF,
|
|
||||||
LightGoldenRodYellow, // = 0xFAFAD2,
|
|
||||||
LightGray, // = 0xD3D3D3,
|
|
||||||
LightGrey, // = 0xD3D3D3
|
|
||||||
LightGreen, // = 0x90EE90,
|
|
||||||
LightPink, // = 0xFFB6C1,
|
|
||||||
LightSalmon, // = 0xFFA07A,
|
|
||||||
LightSeaGreen, // = 0x20B2AA,
|
|
||||||
LightSkyBlue, // = 0x87CEFA,
|
|
||||||
LightSlateGray, // = 0x778899,
|
|
||||||
LightSlateGrey, // = 0x778899
|
|
||||||
LightSteelBlue, // = 0xB0C4DE,
|
|
||||||
LightYellow, // = 0xFFFFE0,
|
|
||||||
Lime, // = 0x00FF00,
|
|
||||||
LimeGreen, // = 0x32CD32,
|
|
||||||
Linen, // = 0xFAF0E6,
|
|
||||||
Magenta, // = 0xFF00FF
|
|
||||||
Maroon, // = 0x800000,
|
|
||||||
MediumAquaMarine, // = 0x66CDAA,
|
|
||||||
MediumBlue, // = 0x0000CD,
|
|
||||||
MediumOrchid, // = 0xBA55D3,
|
|
||||||
MediumPurple, // = 0x9370DB,
|
|
||||||
MediumSeaGreen, // = 0x3CB371,
|
|
||||||
MediumSlateBlue, // = 0x7B68EE,
|
|
||||||
MediumSpringGreen, // = 0x00FA9A,
|
|
||||||
MediumTurquoise, // = 0x48D1CC,
|
|
||||||
MediumVioletRed, // = 0xC71585,
|
|
||||||
MidnightBlue, // = 0x191970,
|
|
||||||
MintCream, // = 0xF5FFFA,
|
|
||||||
MistyRose, // = 0xFFE4E1,
|
|
||||||
Moccasin, // = 0xFFE4B5,
|
|
||||||
NavajoWhite, // = 0xFFDEAD,
|
|
||||||
Navy, // = 0x000080,
|
|
||||||
OldLace, // = 0xFDF5E6,
|
|
||||||
Olive, // = 0x808000,
|
|
||||||
OliveDrab, // = 0x6B8E23,
|
|
||||||
Orange, // = 0xFFA500,
|
|
||||||
OrangeRed, // = 0xFF4500,
|
|
||||||
Orchid, // = 0xDA70D6,
|
|
||||||
PaleGoldenRod, // = 0xEEE8AA,
|
|
||||||
PaleGreen, // = 0x98FB98,
|
|
||||||
PaleTurquoise, // = 0xAFEEEE,
|
|
||||||
PaleVioletRed, // = 0xDB7093,
|
|
||||||
PapayaWhip, // = 0xFFEFD5,
|
|
||||||
PeachPuff, // = 0xFFDAB9,
|
|
||||||
Peru, // = 0xCD853F,
|
|
||||||
Pink, // = 0xFFC0CB,
|
|
||||||
Plum, // = 0xDDA0DD,
|
|
||||||
PowderBlue, // = 0xB0E0E6,
|
|
||||||
Purple, // = 0x800080,
|
|
||||||
RebeccaPurple, // = 0x663399,
|
|
||||||
Red, // = 0xFF0000,
|
|
||||||
RosyBrown, // = 0xBC8F8F,
|
|
||||||
RoyalBlue, // = 0x4169E1,
|
|
||||||
SaddleBrown, // = 0x8B4513,
|
|
||||||
Salmon, // = 0xFA8072,
|
|
||||||
SandyBrown, // = 0xF4A460,
|
|
||||||
SeaGreen, // = 0x2E8B57,
|
|
||||||
SeaShell, // = 0xFFF5EE,
|
|
||||||
Sienna, // = 0xA0522D,
|
|
||||||
Silver, // = 0xC0C0C0,
|
|
||||||
SkyBlue, // = 0x87CEEB,
|
|
||||||
SlateBlue, // = 0x6A5ACD,
|
|
||||||
SlateGray, // = 0x708090,
|
|
||||||
SlateGrey, // = 0x708090
|
|
||||||
Snow, // = 0xFFFAFA,
|
|
||||||
SpringGreen, // = 0x00FF7F,
|
|
||||||
SteelBlue, // = 0x4682B4,
|
|
||||||
Tan, // = 0xD2B48C,
|
|
||||||
Teal, // = 0x008080,
|
|
||||||
Thistle, // = 0xD8BFD8,
|
|
||||||
Tomato, // = 0xFF6347,
|
|
||||||
Turquoise, // = 0x40E0D0,
|
|
||||||
Violet, // = 0xEE82EE,
|
|
||||||
Wheat, // = 0xF5DEB3,
|
|
||||||
White, // = 0xFFFFFF,
|
|
||||||
WhiteSmoke, // = 0xF5F5F5,
|
|
||||||
Yellow, // = 0xFFFF00,
|
|
||||||
YellowGreen, // = 0x9ACD32,
|
|
||||||
#[allow(dead_code)]
|
|
||||||
RGB(u8, u8, u8),
|
|
||||||
#[allow(dead_code)]
|
|
||||||
RGBA(u8, u8, u8, u8),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::UpperHex for Color {
|
|
||||||
#[allow(clippy::match_same_arms, clippy::many_single_char_names)]
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
// I want them all to be on separate lines so doing things with regex or multiple cursors is easier
|
|
||||||
match self {
|
|
||||||
Self::AliceBlue => write!(f, "#F0F8FF"),
|
|
||||||
Self::AntiqueWhite => write!(f, "#FAEBD7"),
|
|
||||||
Self::Aqua => write!(f, "#00FFFF"),
|
|
||||||
Self::Aquamarine => write!(f, "#7FFFD4"),
|
|
||||||
Self::Azure => write!(f, "#F0FFFF"),
|
|
||||||
Self::Beige => write!(f, "#F5F5DC"),
|
|
||||||
Self::Bisque => write!(f, "#FFE4C4"),
|
|
||||||
Self::Black => write!(f, "#000000"),
|
|
||||||
Self::BlanchedAlmond => write!(f, "#FFEBCD"),
|
|
||||||
Self::Blue => write!(f, "#0000FF"),
|
|
||||||
Self::BlueViolet => write!(f, "#8A2BE2"),
|
|
||||||
Self::Brown => write!(f, "#A52A2A"),
|
|
||||||
Self::BurlyWood => write!(f, "#DEB887"),
|
|
||||||
Self::CadetBlue => write!(f, "#5F9EA0"),
|
|
||||||
Self::Chartreuse => write!(f, "#7FFF00"),
|
|
||||||
Self::Chocolate => write!(f, "#D2691E"),
|
|
||||||
Self::Coral => write!(f, "#FF7F50"),
|
|
||||||
Self::CornflowerBlue => write!(f, "#6495ED"),
|
|
||||||
Self::Cornsilk => write!(f, "#FFF8DC"),
|
|
||||||
Self::Crimson => write!(f, "#DC143C"),
|
|
||||||
Self::Cyan => write!(f, "#00FFFF"),
|
|
||||||
Self::DarkBlue => write!(f, "#00008B"),
|
|
||||||
Self::DarkCyan => write!(f, "#008B8B"),
|
|
||||||
Self::DarkGoldenRod => write!(f, "#B8860B"),
|
|
||||||
Self::DarkGray => write!(f, "#A9A9A9"),
|
|
||||||
Self::DarkGrey => write!(f, "#A9A9A9"),
|
|
||||||
Self::DarkGreen => write!(f, "#006400"),
|
|
||||||
Self::DarkKhaki => write!(f, "#BDB76B"),
|
|
||||||
Self::DarkMagenta => write!(f, "#8B008B"),
|
|
||||||
Self::DarkOliveGreen => write!(f, "#556B2F"),
|
|
||||||
Self::DarkOrange => write!(f, "#FF8C00"),
|
|
||||||
Self::DarkOrchid => write!(f, "#9932CC"),
|
|
||||||
Self::DarkRed => write!(f, "#8B0000"),
|
|
||||||
Self::DarkSalmon => write!(f, "#E9967A"),
|
|
||||||
Self::DarkSeaGreen => write!(f, "#8FBC8F"),
|
|
||||||
Self::DarkSlateBlue => write!(f, "#483D8B"),
|
|
||||||
Self::DarkSlateGray => write!(f, "#2F4F4F"),
|
|
||||||
Self::DarkSlateGrey => write!(f, "#2F4F4F"),
|
|
||||||
Self::DarkTurquoise => write!(f, "#00CED1"),
|
|
||||||
Self::DarkViolet => write!(f, "#9400D3"),
|
|
||||||
Self::DeepPink => write!(f, "#FF1493"),
|
|
||||||
Self::DeepSkyBlue => write!(f, "#00BFFF"),
|
|
||||||
Self::DimGray => write!(f, "#696969"),
|
|
||||||
Self::DimGrey => write!(f, "#696969"),
|
|
||||||
Self::DodgerBlue => write!(f, "#1E90FF"),
|
|
||||||
Self::FireBrick => write!(f, "#B22222"),
|
|
||||||
Self::FloralWhite => write!(f, "#FFFAF0"),
|
|
||||||
Self::ForestGreen => write!(f, "#228B22"),
|
|
||||||
Self::Fuchsia => write!(f, "#FF00FF"),
|
|
||||||
Self::Gainsboro => write!(f, "#DCDCDC"),
|
|
||||||
Self::GhostWhite => write!(f, "#F8F8FF"),
|
|
||||||
Self::Gold => write!(f, "#FFD700"),
|
|
||||||
Self::GoldenRod => write!(f, "#DAA520"),
|
|
||||||
Self::Gray => write!(f, "#808080"),
|
|
||||||
Self::Grey => write!(f, "#808080"),
|
|
||||||
Self::Green => write!(f, "#008000"),
|
|
||||||
Self::GreenYellow => write!(f, "#ADFF2F"),
|
|
||||||
Self::HoneyDew => write!(f, "#F0FFF0"),
|
|
||||||
Self::HotPink => write!(f, "#FF69B4"),
|
|
||||||
Self::IndianRed => write!(f, "#CD5C5C"),
|
|
||||||
Self::Indigo => write!(f, "#4B0082"),
|
|
||||||
Self::Ivory => write!(f, "#FFFFF0"),
|
|
||||||
Self::Khaki => write!(f, "#F0E68C"),
|
|
||||||
Self::Lavender => write!(f, "#E6E6FA"),
|
|
||||||
Self::LavenderBlush => write!(f, "#FFF0F5"),
|
|
||||||
Self::LawnGreen => write!(f, "#7CFC00"),
|
|
||||||
Self::LemonChiffon => write!(f, "#FFFACD"),
|
|
||||||
Self::LightBlue => write!(f, "#ADD8E6"),
|
|
||||||
Self::LightCoral => write!(f, "#F08080"),
|
|
||||||
Self::LightCyan => write!(f, "#E0FFFF"),
|
|
||||||
Self::LightGoldenRodYellow => write!(f, "#FAFAD2"),
|
|
||||||
Self::LightGray => write!(f, "#D3D3D3"),
|
|
||||||
Self::LightGrey => write!(f, "#D3D3D3"),
|
|
||||||
Self::LightGreen => write!(f, "#90EE90"),
|
|
||||||
Self::LightPink => write!(f, "#FFB6C1"),
|
|
||||||
Self::LightSalmon => write!(f, "#FFA07A"),
|
|
||||||
Self::LightSeaGreen => write!(f, "#20B2AA"),
|
|
||||||
Self::LightSkyBlue => write!(f, "#87CEFA"),
|
|
||||||
Self::LightSlateGray => write!(f, "#778899"),
|
|
||||||
Self::LightSlateGrey => write!(f, "#778899"),
|
|
||||||
Self::LightSteelBlue => write!(f, "#B0C4DE"),
|
|
||||||
Self::LightYellow => write!(f, "#FFFFE0"),
|
|
||||||
Self::Lime => write!(f, "#00FF00"),
|
|
||||||
Self::LimeGreen => write!(f, "#32CD32"),
|
|
||||||
Self::Linen => write!(f, "#FAF0E6"),
|
|
||||||
Self::Magenta => write!(f, "#FF00FF"),
|
|
||||||
Self::Maroon => write!(f, "#800000"),
|
|
||||||
Self::MediumAquaMarine => write!(f, "#66CDAA"),
|
|
||||||
Self::MediumBlue => write!(f, "#0000CD"),
|
|
||||||
Self::MediumOrchid => write!(f, "#BA55D3"),
|
|
||||||
Self::MediumPurple => write!(f, "#9370DB"),
|
|
||||||
Self::MediumSeaGreen => write!(f, "#3CB371"),
|
|
||||||
Self::MediumSlateBlue => write!(f, "#7B68EE"),
|
|
||||||
Self::MediumSpringGreen => write!(f, "#00FA9A"),
|
|
||||||
Self::MediumTurquoise => write!(f, "#48D1CC"),
|
|
||||||
Self::MediumVioletRed => write!(f, "#C71585"),
|
|
||||||
Self::MidnightBlue => write!(f, "#191970"),
|
|
||||||
Self::MintCream => write!(f, "#F5FFFA"),
|
|
||||||
Self::MistyRose => write!(f, "#FFE4E1"),
|
|
||||||
Self::Moccasin => write!(f, "#FFE4B5"),
|
|
||||||
Self::NavajoWhite => write!(f, "#FFDEAD"),
|
|
||||||
Self::Navy => write!(f, "#000080"),
|
|
||||||
Self::OldLace => write!(f, "#FDF5E6"),
|
|
||||||
Self::Olive => write!(f, "#808000"),
|
|
||||||
Self::OliveDrab => write!(f, "#6B8E23"),
|
|
||||||
Self::Orange => write!(f, "#FFA500"),
|
|
||||||
Self::OrangeRed => write!(f, "#FF4500"),
|
|
||||||
Self::Orchid => write!(f, "#DA70D6"),
|
|
||||||
Self::PaleGoldenRod => write!(f, "#EEE8AA"),
|
|
||||||
Self::PaleGreen => write!(f, "#98FB98"),
|
|
||||||
Self::PaleTurquoise => write!(f, "#AFEEEE"),
|
|
||||||
Self::PaleVioletRed => write!(f, "#DB7093"),
|
|
||||||
Self::PapayaWhip => write!(f, "#FFEFD5"),
|
|
||||||
Self::PeachPuff => write!(f, "#FFDAB9"),
|
|
||||||
Self::Peru => write!(f, "#CD853F"),
|
|
||||||
Self::Pink => write!(f, "#FFC0CB"),
|
|
||||||
Self::Plum => write!(f, "#DDA0DD"),
|
|
||||||
Self::PowderBlue => write!(f, "#B0E0E6"),
|
|
||||||
Self::Purple => write!(f, "#800080"),
|
|
||||||
Self::RebeccaPurple => write!(f, "#663399"),
|
|
||||||
Self::Red => write!(f, "#FF0000"),
|
|
||||||
Self::RosyBrown => write!(f, "#BC8F8F"),
|
|
||||||
Self::RoyalBlue => write!(f, "#4169E1"),
|
|
||||||
Self::SaddleBrown => write!(f, "#8B4513"),
|
|
||||||
Self::Salmon => write!(f, "#FA8072"),
|
|
||||||
Self::SandyBrown => write!(f, "#F4A460"),
|
|
||||||
Self::SeaGreen => write!(f, "#2E8B57"),
|
|
||||||
Self::SeaShell => write!(f, "#FFF5EE"),
|
|
||||||
Self::Sienna => write!(f, "#A0522D"),
|
|
||||||
Self::Silver => write!(f, "#C0C0C0"),
|
|
||||||
Self::SkyBlue => write!(f, "#87CEEB"),
|
|
||||||
Self::SlateBlue => write!(f, "#6A5ACD"),
|
|
||||||
Self::SlateGray => write!(f, "#708090"),
|
|
||||||
Self::SlateGrey => write!(f, "#708090"),
|
|
||||||
Self::Snow => write!(f, "#FFFAFA"),
|
|
||||||
Self::SpringGreen => write!(f, "#00FF7F"),
|
|
||||||
Self::SteelBlue => write!(f, "#4682B4"),
|
|
||||||
Self::Tan => write!(f, "#D2B48C"),
|
|
||||||
Self::Teal => write!(f, "#008080"),
|
|
||||||
Self::Thistle => write!(f, "#D8BFD8"),
|
|
||||||
Self::Tomato => write!(f, "#FF6347"),
|
|
||||||
Self::Turquoise => write!(f, "#40E0D0"),
|
|
||||||
Self::Violet => write!(f, "#EE82EE"),
|
|
||||||
Self::Wheat => write!(f, "#F5DEB3"),
|
|
||||||
Self::White => write!(f, "#FFFFFF"),
|
|
||||||
Self::WhiteSmoke => write!(f, "#F5F5F5"),
|
|
||||||
Self::Yellow => write!(f, "#FFFF00"),
|
|
||||||
Self::YellowGreen => write!(f, "#9ACD32"),
|
|
||||||
Self::RGB(r, g, b) => write!(f, "#{:X}{:X}{:X}", r, g, b),
|
|
||||||
Self::RGBA(r, g, b, a) => write!(f, "#{:X}{:X}{:X}{:X}", r, g, b, a),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for Color {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
write!(f, "{:X}", self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<&str> for Color {
|
|
||||||
type Error = &'static str;
|
|
||||||
|
|
||||||
fn try_from(string: &str) -> Result<Self, Self::Error> {
|
|
||||||
match string {
|
|
||||||
"aliceblue" => Ok(Self::AliceBlue),
|
|
||||||
"antiquewhite" => Ok(Self::AntiqueWhite),
|
|
||||||
"aqua" => Ok(Self::Aqua),
|
|
||||||
"aquamarine" => Ok(Self::Aquamarine),
|
|
||||||
"azure" => Ok(Self::Azure),
|
|
||||||
"beige" => Ok(Self::Beige),
|
|
||||||
"bisque" => Ok(Self::Bisque),
|
|
||||||
"black" => Ok(Self::Black),
|
|
||||||
"blanchedalmond" => Ok(Self::BlanchedAlmond),
|
|
||||||
"blue" => Ok(Self::Blue),
|
|
||||||
"blueviolet" => Ok(Self::BlueViolet),
|
|
||||||
"brown" => Ok(Self::Brown),
|
|
||||||
"burlywood" => Ok(Self::BurlyWood),
|
|
||||||
"cadetblue" => Ok(Self::CadetBlue),
|
|
||||||
"chartreuse" => Ok(Self::Chartreuse),
|
|
||||||
"chocolate" => Ok(Self::Chocolate),
|
|
||||||
"coral" => Ok(Self::Coral),
|
|
||||||
"cornflowerblue" => Ok(Self::CornflowerBlue),
|
|
||||||
"cornsilk" => Ok(Self::Cornsilk),
|
|
||||||
"crimson" => Ok(Self::Crimson),
|
|
||||||
"cyan" => Ok(Self::Cyan),
|
|
||||||
"darkblue" => Ok(Self::DarkBlue),
|
|
||||||
"darkcyan" => Ok(Self::DarkCyan),
|
|
||||||
"darkgoldenrod" => Ok(Self::DarkGoldenRod),
|
|
||||||
"darkgray" => Ok(Self::DarkGray),
|
|
||||||
"darkgrey" => Ok(Self::DarkGrey),
|
|
||||||
"darkgreen" => Ok(Self::DarkGreen),
|
|
||||||
"darkkhaki" => Ok(Self::DarkKhaki),
|
|
||||||
"darkmagenta" => Ok(Self::DarkMagenta),
|
|
||||||
"darkolivegreen" => Ok(Self::DarkOliveGreen),
|
|
||||||
"darkorange" => Ok(Self::DarkOrange),
|
|
||||||
"darkorchid" => Ok(Self::DarkOrchid),
|
|
||||||
"darkred" => Ok(Self::DarkRed),
|
|
||||||
"darksalmon" => Ok(Self::DarkSalmon),
|
|
||||||
"darkseagreen" => Ok(Self::DarkSeaGreen),
|
|
||||||
"darkslateblue" => Ok(Self::DarkSlateBlue),
|
|
||||||
"darkslategray" => Ok(Self::DarkSlateGray),
|
|
||||||
"darkslategrey" => Ok(Self::DarkSlateGrey),
|
|
||||||
"darkturquoise" => Ok(Self::DarkTurquoise),
|
|
||||||
"darkviolet" => Ok(Self::DarkViolet),
|
|
||||||
"deeppink" => Ok(Self::DeepPink),
|
|
||||||
"deepskyblue" => Ok(Self::DeepSkyBlue),
|
|
||||||
"dimgray" => Ok(Self::DimGray),
|
|
||||||
"dimgrey" => Ok(Self::DimGrey),
|
|
||||||
"dodgerblue" => Ok(Self::DodgerBlue),
|
|
||||||
"firebrick" => Ok(Self::FireBrick),
|
|
||||||
"floralwhite" => Ok(Self::FloralWhite),
|
|
||||||
"forestgreen" => Ok(Self::ForestGreen),
|
|
||||||
"fuchsia" => Ok(Self::Fuchsia),
|
|
||||||
"gainsboro" => Ok(Self::Gainsboro),
|
|
||||||
"ghostwhite" => Ok(Self::GhostWhite),
|
|
||||||
"gold" => Ok(Self::Gold),
|
|
||||||
"goldenrod" => Ok(Self::GoldenRod),
|
|
||||||
"gray" => Ok(Self::Gray),
|
|
||||||
"grey" => Ok(Self::Grey),
|
|
||||||
"green" => Ok(Self::Green),
|
|
||||||
"greenyellow" => Ok(Self::GreenYellow),
|
|
||||||
"honeydew" => Ok(Self::HoneyDew),
|
|
||||||
"hotpink" => Ok(Self::HotPink),
|
|
||||||
"indianred" => Ok(Self::IndianRed),
|
|
||||||
"indigo" => Ok(Self::Indigo),
|
|
||||||
"ivory" => Ok(Self::Ivory),
|
|
||||||
"khaki" => Ok(Self::Khaki),
|
|
||||||
"lavender" => Ok(Self::Lavender),
|
|
||||||
"lavenderblush" => Ok(Self::LavenderBlush),
|
|
||||||
"lawngreen" => Ok(Self::LawnGreen),
|
|
||||||
"lemonchiffon" => Ok(Self::LemonChiffon),
|
|
||||||
"lightblue" => Ok(Self::LightBlue),
|
|
||||||
"lightcoral" => Ok(Self::LightCoral),
|
|
||||||
"lightcyan" => Ok(Self::LightCyan),
|
|
||||||
"lightgoldenrodyellow" => Ok(Self::LightGoldenRodYellow),
|
|
||||||
"lightgray" => Ok(Self::LightGray),
|
|
||||||
"lightgrey" => Ok(Self::LightGrey),
|
|
||||||
"lightgreen" => Ok(Self::LightGreen),
|
|
||||||
"lightpink" => Ok(Self::LightPink),
|
|
||||||
"lightsalmon" => Ok(Self::LightSalmon),
|
|
||||||
"lightseagreen" => Ok(Self::LightSeaGreen),
|
|
||||||
"lightskyblue" => Ok(Self::LightSkyBlue),
|
|
||||||
"lightslategray" => Ok(Self::LightSlateGray),
|
|
||||||
"lightslategrey" => Ok(Self::LightSlateGrey),
|
|
||||||
"lightsteelblue" => Ok(Self::LightSteelBlue),
|
|
||||||
"lightyellow" => Ok(Self::LightYellow),
|
|
||||||
"lime" => Ok(Self::Lime),
|
|
||||||
"limegreen" => Ok(Self::LimeGreen),
|
|
||||||
"linen" => Ok(Self::Linen),
|
|
||||||
"magenta" => Ok(Self::Magenta),
|
|
||||||
"maroon" => Ok(Self::Maroon),
|
|
||||||
"mediumaquamarine" => Ok(Self::MediumAquaMarine),
|
|
||||||
"mediumblue" => Ok(Self::MediumBlue),
|
|
||||||
"mediumorchid" => Ok(Self::MediumOrchid),
|
|
||||||
"mediumpurple" => Ok(Self::MediumPurple),
|
|
||||||
"mediumseagreen" => Ok(Self::MediumSeaGreen),
|
|
||||||
"mediumslateblue" => Ok(Self::MediumSlateBlue),
|
|
||||||
"mediumspringgreen" => Ok(Self::MediumSpringGreen),
|
|
||||||
"mediumturquoise" => Ok(Self::MediumTurquoise),
|
|
||||||
"mediumvioletred" => Ok(Self::MediumVioletRed),
|
|
||||||
"midnightblue" => Ok(Self::MidnightBlue),
|
|
||||||
"mintcream" => Ok(Self::MintCream),
|
|
||||||
"mistyrose" => Ok(Self::MistyRose),
|
|
||||||
"moccasin" => Ok(Self::Moccasin),
|
|
||||||
"navajowhite" => Ok(Self::NavajoWhite),
|
|
||||||
"navy" => Ok(Self::Navy),
|
|
||||||
"oldlace" => Ok(Self::OldLace),
|
|
||||||
"olive" => Ok(Self::Olive),
|
|
||||||
"olivedrab" => Ok(Self::OliveDrab),
|
|
||||||
"orange" => Ok(Self::Orange),
|
|
||||||
"orangered" => Ok(Self::OrangeRed),
|
|
||||||
"orchid" => Ok(Self::Orchid),
|
|
||||||
"palegoldenrod" => Ok(Self::PaleGoldenRod),
|
|
||||||
"palegreen" => Ok(Self::PaleGreen),
|
|
||||||
"paleturquoise" => Ok(Self::PaleTurquoise),
|
|
||||||
"palevioletred" => Ok(Self::PaleVioletRed),
|
|
||||||
"papayawhip" => Ok(Self::PapayaWhip),
|
|
||||||
"peachpuff" => Ok(Self::PeachPuff),
|
|
||||||
"peru" => Ok(Self::Peru),
|
|
||||||
"pink" => Ok(Self::Pink),
|
|
||||||
"plum" => Ok(Self::Plum),
|
|
||||||
"powderblue" => Ok(Self::PowderBlue),
|
|
||||||
"purple" => Ok(Self::Purple),
|
|
||||||
"rebeccapurple" => Ok(Self::RebeccaPurple),
|
|
||||||
"red" => Ok(Self::Red),
|
|
||||||
"rosybrown" => Ok(Self::RosyBrown),
|
|
||||||
"royalblue" => Ok(Self::RoyalBlue),
|
|
||||||
"saddlebrown" => Ok(Self::SaddleBrown),
|
|
||||||
"salmon" => Ok(Self::Salmon),
|
|
||||||
"sandybrown" => Ok(Self::SandyBrown),
|
|
||||||
"seagreen" => Ok(Self::SeaGreen),
|
|
||||||
"seashell" => Ok(Self::SeaShell),
|
|
||||||
"sienna" => Ok(Self::Sienna),
|
|
||||||
"silver" => Ok(Self::Silver),
|
|
||||||
"skyblue" => Ok(Self::SkyBlue),
|
|
||||||
"slateblue" => Ok(Self::SlateBlue),
|
|
||||||
"slategray" => Ok(Self::SlateGray),
|
|
||||||
"slategrey" => Ok(Self::SlateGrey),
|
|
||||||
"snow" => Ok(Self::Snow),
|
|
||||||
"springgreen" => Ok(Self::SpringGreen),
|
|
||||||
"steelblue" => Ok(Self::SteelBlue),
|
|
||||||
"tan" => Ok(Self::Tan),
|
|
||||||
"teal" => Ok(Self::Teal),
|
|
||||||
"thistle" => Ok(Self::Thistle),
|
|
||||||
"tomato" => Ok(Self::Tomato),
|
|
||||||
"turquoise" => Ok(Self::Turquoise),
|
|
||||||
"violet" => Ok(Self::Violet),
|
|
||||||
"wheat" => Ok(Self::Wheat),
|
|
||||||
"white" => Ok(Self::White),
|
|
||||||
"whitesmoke" => Ok(Self::WhiteSmoke),
|
|
||||||
"yellow" => Ok(Self::Yellow),
|
|
||||||
"yellowgreen" => Ok(Self::YellowGreen),
|
|
||||||
_ => Err("invalid color"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
use name::ColorName;
|
pub(crate) use name::ColorName;
|
||||||
|
|
||||||
mod name;
|
mod name;
|
||||||
|
|
||||||
@ -13,6 +13,12 @@ pub(crate) struct Color {
|
|||||||
repr: ColorRepr,
|
repr: ColorRepr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Color {
|
||||||
|
pub const fn new(red: u16, green: u16, blue: u16, alpha: u16, repr: ColorRepr) -> Self {
|
||||||
|
Color { red, green, blue, alpha, repr }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Display for Color {
|
impl Display for Color {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self.repr {
|
match self.repr {
|
||||||
@ -35,7 +41,7 @@ impl Display for Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||||
enum ColorRepr {
|
pub(crate) enum ColorRepr {
|
||||||
Name(ColorName),
|
Name(ColorName),
|
||||||
Hex3,
|
Hex3,
|
||||||
Hex6,
|
Hex6,
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
use std::convert::TryFrom;
|
use std::convert::{Into, TryFrom};
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
|
use super::{Color, ColorRepr};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||||
pub(crate) enum ColorName {
|
pub(crate) enum ColorName {
|
||||||
AliceBlue, // = 0xF0F8FF,
|
AliceBlue, // = 0xF0F8FF,
|
||||||
@ -467,3 +469,158 @@ impl TryFrom<&str> for ColorName {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Into<Color> for ColorName {
|
||||||
|
fn into(self) -> Color {
|
||||||
|
match self {
|
||||||
|
Self::AliceBlue => Color::new(0xF0, 0xF8, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::AntiqueWhite => Color::new(0xFA, 0xEB, 0xD7, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Aqua => Color::new(0x00, 0xFF, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Aquamarine => Color::new(0x7F, 0xFF, 0xD4, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Azure => Color::new(0xF0, 0xFF, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Beige => Color::new(0xF5, 0xF5, 0xDC, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Bisque => Color::new(0xFF, 0xE4, 0xC4, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Black => Color::new(0x00, 0x00, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::BlanchedAlmond => Color::new(0xFF, 0xEB, 0xCD, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Blue => Color::new(0x00, 0x00, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::BlueViolet => Color::new(0x8A, 0x2B, 0xE2, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Brown => Color::new(0xA5, 0x2A, 0x2A, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::BurlyWood => Color::new(0xDE, 0xB8, 0x87, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::CadetBlue => Color::new(0x5F, 0x9E, 0xA0, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Chartreuse => Color::new(0x7F, 0xFF, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Chocolate => Color::new(0xD2, 0x69, 0x1E, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Coral => Color::new(0xFF, 0x7F, 0x50, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::CornflowerBlue => Color::new(0x64, 0x95, 0xED, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Cornsilk => Color::new(0xFF, 0xF8, 0xDC, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Crimson => Color::new(0xDC, 0x14, 0x3C, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Cyan => Color::new(0x00, 0xFF, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkBlue => Color::new(0x00, 0x00, 0x8B, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkCyan => Color::new(0x00, 0x8B, 0x8B, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkGoldenRod => Color::new(0xB8, 0x86, 0x0B, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkGray => Color::new(0xA9, 0xA9, 0xA9, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkGrey => Color::new(0xA9, 0xA9, 0xA9, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkGreen => Color::new(0x00, 0x64, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkKhaki => Color::new(0xBD, 0xB7, 0x6B, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkMagenta => Color::new(0x8B, 0x00, 0x8B, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkOliveGreen => Color::new(0x55, 0x6B, 0x2F, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkOrange => Color::new(0xFF, 0x8C, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkOrchid => Color::new(0x99, 0x32, 0xCC, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkRed => Color::new(0x8B, 0x00, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkSalmon => Color::new(0xE9, 0x96, 0x7A, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkSeaGreen => Color::new(0x8F, 0xBC, 0x8F, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkSlateBlue => Color::new(0x48, 0x3D, 0x8B, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkSlateGray => Color::new(0x2F, 0x4F, 0x4F, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkSlateGrey => Color::new(0x2F, 0x4F, 0x4F, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkTurquoise => Color::new(0x00, 0xCE, 0xD1, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DarkViolet => Color::new(0x94, 0x00, 0xD3, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DeepPink => Color::new(0xFF, 0x14, 0x93, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DeepSkyBlue => Color::new(0x00, 0xBF, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DimGray => Color::new(0x69, 0x69, 0x69, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DimGrey => Color::new(0x69, 0x69, 0x69, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::DodgerBlue => Color::new(0x1E, 0x90, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::FireBrick => Color::new(0xB2, 0x22, 0x22, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::FloralWhite => Color::new(0xFF, 0xFA, 0xF0, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::ForestGreen => Color::new(0x22, 0x8B, 0x22, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Fuchsia => Color::new(0xFF, 0x00, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Gainsboro => Color::new(0xDC, 0xDC, 0xDC, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::GhostWhite => Color::new(0xF8, 0xF8, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Gold => Color::new(0xFF, 0xD7, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::GoldenRod => Color::new(0xDA, 0xA5, 0x20, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Gray => Color::new(0x80, 0x80, 0x80, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Grey => Color::new(0x80, 0x80, 0x80, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Green => Color::new(0x00, 0x80, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::GreenYellow => Color::new(0xAD, 0xFF, 0x2F, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::HoneyDew => Color::new(0xF0, 0xFF, 0xF0, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::HotPink => Color::new(0xFF, 0x69, 0xB4, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::IndianRed => Color::new(0xCD, 0x5C, 0x5C, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Indigo => Color::new(0x4B, 0x00, 0x82, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Ivory => Color::new(0xFF, 0xFF, 0xF0, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Khaki => Color::new(0xF0, 0xE6, 0x8C, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Lavender => Color::new(0xE6, 0xE6, 0xFA, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LavenderBlush => Color::new(0xFF, 0xF0, 0xF5, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LawnGreen => Color::new(0x7C, 0xFC, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LemonChiffon => Color::new(0xFF, 0xFA, 0xCD, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightBlue => Color::new(0xAD, 0xD8, 0xE6, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightCoral => Color::new(0xF0, 0x80, 0x80, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightCyan => Color::new(0xE0, 0xFF, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightGoldenRodYellow => Color::new(0xFA, 0xFA, 0xD2, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightGray => Color::new(0xD3, 0xD3, 0xD3, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightGrey => Color::new(0xD3, 0xD3, 0xD3, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightGreen => Color::new(0x90, 0xEE, 0x90, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightPink => Color::new(0xFF, 0xB6, 0xC1, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightSalmon => Color::new(0xFF, 0xA0, 0x7A, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightSeaGreen => Color::new(0x20, 0xB2, 0xAA, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightSkyBlue => Color::new(0x87, 0xCE, 0xFA, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightSlateGray => Color::new(0x77, 0x88, 0x99, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightSlateGrey => Color::new(0x77, 0x88, 0x99, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightSteelBlue => Color::new(0xB0, 0xC4, 0xDE, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LightYellow => Color::new(0xFF, 0xFF, 0xE0, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Lime => Color::new(0x00, 0xFF, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::LimeGreen => Color::new(0x32, 0xCD, 0x32, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Linen => Color::new(0xFA, 0xF0, 0xE6, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Magenta => Color::new(0xFF, 0x00, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Maroon => Color::new(0x80, 0x00, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MediumAquaMarine => Color::new(0x66, 0xCD, 0xAA, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MediumBlue => Color::new(0x00, 0x00, 0xCD, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MediumOrchid => Color::new(0xBA, 0x55, 0xD3, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MediumPurple => Color::new(0x93, 0x70, 0xDB, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MediumSeaGreen => Color::new(0x3C, 0xB3, 0x71, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MediumSlateBlue => Color::new(0x7B, 0x68, 0xEE, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MediumSpringGreen => Color::new(0x00, 0xFA, 0x9A, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MediumTurquoise => Color::new(0x48, 0xD1, 0xCC, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MediumVioletRed => Color::new(0xC7, 0x15, 0x85, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MidnightBlue => Color::new(0x19, 0x19, 0x70, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MintCream => Color::new(0xF5, 0xFF, 0xFA, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::MistyRose => Color::new(0xFF, 0xE4, 0xE1, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Moccasin => Color::new(0xFF, 0xE4, 0xB5, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::NavajoWhite => Color::new(0xFF, 0xDE, 0xAD, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Navy => Color::new(0x00, 0x00, 0x80, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::OldLace => Color::new(0xFD, 0xF5, 0xE6, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Olive => Color::new(0x80, 0x80, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::OliveDrab => Color::new(0x6B, 0x8E, 0x23, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Orange => Color::new(0xFF, 0xA5, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::OrangeRed => Color::new(0xFF, 0x45, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Orchid => Color::new(0xDA, 0x70, 0xD6, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::PaleGoldenRod => Color::new(0xEE, 0xE8, 0xAA, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::PaleGreen => Color::new(0x98, 0xFB, 0x98, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::PaleTurquoise => Color::new(0xAF, 0xEE, 0xEE, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::PaleVioletRed => Color::new(0xDB, 0x70, 0x93, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::PapayaWhip => Color::new(0xFF, 0xEF, 0xD5, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::PeachPuff => Color::new(0xFF, 0xDA, 0xB9, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Peru => Color::new(0xCD, 0x85, 0x3F, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Pink => Color::new(0xFF, 0xC0, 0xCB, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Plum => Color::new(0xDD, 0xA0, 0xDD, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::PowderBlue => Color::new(0xB0, 0xE0, 0xE6, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Purple => Color::new(0x80, 0x00, 0x80, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::RebeccaPurple => Color::new(0x66, 0x33, 0x99, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Red => Color::new(0xFF, 0x00, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::RosyBrown => Color::new(0xBC, 0x8F, 0x8F, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::RoyalBlue => Color::new(0x41, 0x69, 0xE1, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SaddleBrown => Color::new(0x8B, 0x45, 0x13, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Salmon => Color::new(0xFA, 0x80, 0x72, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SandyBrown => Color::new(0xF4, 0xA4, 0x60, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SeaGreen => Color::new(0x2E, 0x8B, 0x57, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SeaShell => Color::new(0xFF, 0xF5, 0xEE, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Sienna => Color::new(0xA0, 0x52, 0x2D, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Silver => Color::new(0xC0, 0xC0, 0xC0, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SkyBlue => Color::new(0x87, 0xCE, 0xEB, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SlateBlue => Color::new(0x6A, 0x5A, 0xCD, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SlateGray => Color::new(0x70, 0x80, 0x90, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SlateGrey => Color::new(0x70, 0x80, 0x90, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Snow => Color::new(0xFF, 0xFA, 0xFA, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SpringGreen => Color::new(0x00, 0xFF, 0x7F, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::SteelBlue => Color::new(0x46, 0x82, 0xB4, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Tan => Color::new(0xD2, 0xB4, 0x8C, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Teal => Color::new(0x00, 0x80, 0x80, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Thistle => Color::new(0xD8, 0xBF, 0xD8, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Tomato => Color::new(0xFF, 0x63, 0x47, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Turquoise => Color::new(0x40, 0xE0, 0xD0, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Violet => Color::new(0xEE, 0x82, 0xEE, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Wheat => Color::new(0xF5, 0xDE, 0xB3, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::White => Color::new(0xFF, 0xFF, 0xFF, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::WhiteSmoke => Color::new(0xF5, 0xF5, 0xF5, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::Yellow => Color::new(0xFF, 0xFF, 0x00, 0xFF, ColorRepr::Name(self)),
|
||||||
|
Self::YellowGreen => Color::new(0x9A, 0xCD, 0x32, 0xFF, ColorRepr::Name(self)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ use std::iter::Peekable;
|
|||||||
use std::str::Chars;
|
use std::str::Chars;
|
||||||
|
|
||||||
use crate::atrule::AtRuleKind;
|
use crate::atrule::AtRuleKind;
|
||||||
|
use crate::color::{ColorName};
|
||||||
use crate::common::{Keyword, Op, Pos, Symbol};
|
use crate::common::{Keyword, Op, Pos, Symbol};
|
||||||
use crate::selector::{Attribute, AttributeKind, CaseKind};
|
use crate::selector::{Attribute, AttributeKind, CaseKind};
|
||||||
use crate::{Token, TokenKind, Whitespace};
|
use crate::{Token, TokenKind, Whitespace};
|
||||||
@ -412,6 +413,10 @@ impl<'a> Lexer<'a> {
|
|||||||
if let Ok(kw) = Keyword::try_from(string.as_ref()) {
|
if let Ok(kw) = Keyword::try_from(string.as_ref()) {
|
||||||
return TokenKind::Keyword(kw);
|
return TokenKind::Keyword(kw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Ok(c) = ColorName::try_from(string.as_ref()) {
|
||||||
|
return TokenKind::Color(c.into());
|
||||||
|
}
|
||||||
|
|
||||||
if string == "-" {
|
if string == "-" {
|
||||||
return TokenKind::Symbol(Symbol::Minus);
|
return TokenKind::Symbol(Symbol::Minus);
|
||||||
|
@ -49,6 +49,7 @@ use std::iter::{Iterator, Peekable};
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::atrule::{AtRule, AtRuleKind};
|
use crate::atrule::{AtRule, AtRuleKind};
|
||||||
|
use crate::color::Color;
|
||||||
use crate::common::{Keyword, Op, Pos, Scope, Symbol, Whitespace};
|
use crate::common::{Keyword, Op, Pos, Scope, Symbol, Whitespace};
|
||||||
use crate::css::Css;
|
use crate::css::Css;
|
||||||
use crate::error::SassError;
|
use crate::error::SassError;
|
||||||
@ -136,6 +137,7 @@ pub(crate) enum TokenKind {
|
|||||||
Attribute(Attribute),
|
Attribute(Attribute),
|
||||||
Op(Op),
|
Op(Op),
|
||||||
MultilineComment(String),
|
MultilineComment(String),
|
||||||
|
Color(Color),
|
||||||
Interpolation,
|
Interpolation,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +148,7 @@ impl Display for TokenKind {
|
|||||||
TokenKind::Ident(s) | TokenKind::Number(s) => write!(f, "{}", s),
|
TokenKind::Ident(s) | TokenKind::Number(s) => write!(f, "{}", s),
|
||||||
TokenKind::Symbol(s) => write!(f, "{}", s),
|
TokenKind::Symbol(s) => write!(f, "{}", s),
|
||||||
TokenKind::AtRule(s) => write!(f, "{}", s),
|
TokenKind::AtRule(s) => write!(f, "{}", s),
|
||||||
|
TokenKind::Color(s) => write!(f, "{}", s),
|
||||||
TokenKind::Op(s) => write!(f, "{}", s),
|
TokenKind::Op(s) => write!(f, "{}", s),
|
||||||
TokenKind::Whitespace(s) => write!(f, "{}", s),
|
TokenKind::Whitespace(s) => write!(f, "{}", s),
|
||||||
TokenKind::Attribute(s) => write!(f, "{}", s),
|
TokenKind::Attribute(s) => write!(f, "{}", s),
|
||||||
|
22
src/value.rs
22
src/value.rs
@ -83,17 +83,16 @@ impl Add for Value {
|
|||||||
|
|
||||||
fn add(self, other: Self) -> Self {
|
fn add(self, other: Self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::Important
|
Self::Important | Self::True | Self::False => match other {
|
||||||
| Self::True
|
Self::Ident(s, QuoteKind::Double) | Self::Ident(s, QuoteKind::Single) => {
|
||||||
| Self::False => match other {
|
Value::Ident(format!("{}{}", self, s), QuoteKind::Double)
|
||||||
Self::Ident(s, QuoteKind::Double)
|
}
|
||||||
| Self::Ident(s, QuoteKind::Single) => Value::Ident(format!("{}{}", self, s), QuoteKind::Double),
|
|
||||||
Self::Null => Value::Ident(self.to_string(), QuoteKind::None),
|
Self::Null => Value::Ident(self.to_string(), QuoteKind::None),
|
||||||
_ => Value::Ident(format!("{}{}", self, other), QuoteKind::None)
|
_ => Value::Ident(format!("{}{}", self, other), QuoteKind::None),
|
||||||
},
|
},
|
||||||
Self::Null => match other {
|
Self::Null => match other {
|
||||||
Self::Null => Self::Null,
|
Self::Null => Self::Null,
|
||||||
_ => Value::Ident(format!("{}{}", self, other), QuoteKind::None)
|
_ => Value::Ident(format!("{}", other), QuoteKind::None),
|
||||||
},
|
},
|
||||||
Self::Dimension(num, unit) => match other {
|
Self::Dimension(num, unit) => match other {
|
||||||
Self::Dimension(num2, unit2) => Value::Dimension(num + num2, unit),
|
Self::Dimension(num2, unit2) => Value::Dimension(num + num2, unit),
|
||||||
@ -250,8 +249,8 @@ impl Value {
|
|||||||
Self::BinaryOp(lhs, op, rhs) => match op {
|
Self::BinaryOp(lhs, op, rhs) => match op {
|
||||||
Op::Plus => *lhs.clone() + *rhs.clone(),
|
Op::Plus => *lhs.clone() + *rhs.clone(),
|
||||||
Op::Minus => *lhs.clone() - *rhs.clone(),
|
Op::Minus => *lhs.clone() - *rhs.clone(),
|
||||||
_ => Self::BinaryOp(lhs.clone(), op.clone(), rhs.clone()),
|
_ => Self::BinaryOp(lhs.clone(), *op, rhs.clone()),
|
||||||
}
|
},
|
||||||
_ => self.clone(),
|
_ => self.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,6 +377,10 @@ impl Value {
|
|||||||
toks.next();
|
toks.next();
|
||||||
s.push_str(i)
|
s.push_str(i)
|
||||||
}
|
}
|
||||||
|
TokenKind::Color(c) => {
|
||||||
|
toks.next();
|
||||||
|
s.push_str(&c.to_string())
|
||||||
|
}
|
||||||
_ => break,
|
_ => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -455,6 +458,7 @@ impl Value {
|
|||||||
}
|
}
|
||||||
Some(Value::Ident(s, QuoteKind::None))
|
Some(Value::Ident(s, QuoteKind::None))
|
||||||
}
|
}
|
||||||
|
TokenKind::Color(c) => Some(Value::Color(c)),
|
||||||
TokenKind::Keyword(Keyword::Important) => Some(Value::Important),
|
TokenKind::Keyword(Keyword::Important) => Some(Value::Important),
|
||||||
TokenKind::Keyword(Keyword::True) => Some(Value::True),
|
TokenKind::Keyword(Keyword::True) => Some(Value::True),
|
||||||
TokenKind::Keyword(Keyword::False) => Some(Value::False),
|
TokenKind::Keyword(Keyword::False) => Some(Value::False),
|
||||||
|
@ -233,4 +233,4 @@ test!(
|
|||||||
// inspect_comma_list,
|
// inspect_comma_list,
|
||||||
// "a {\n color: inspect(1, 2, 3)\n}\n",
|
// "a {\n color: inspect(1, 2, 3)\n}\n",
|
||||||
// "a {\n color: 1, 2, 3;\n}\n"
|
// "a {\n color: 1, 2, 3;\n}\n"
|
||||||
// );
|
// );
|
||||||
|
202
tests/values.rs
202
tests/values.rs
@ -3,8 +3,8 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
test!(comma_list_ident, "a {\n color: red, white, blue;\n}\n");
|
test!(comma_list_ident, "a {\n color: foo, bar, baz;\n}\n");
|
||||||
test!(space_list_ident, "a {\n color: red white blue;\n}\n");
|
test!(space_list_ident, "a {\n color: foo bar baz;\n}\n");
|
||||||
test!(comma_list_number, "a {\n color: 1, 2, 3;\n}\n");
|
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!(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!(comma_space_list_number, "a {\n color: 1 1, 2 2, 3 3;\n}\n");
|
||||||
@ -21,7 +21,7 @@ test!(preserves_keyword_unset, "a {\n color: unset;\n}\n");
|
|||||||
test!(preserves_keyword_nan, "a {\n color: NaN;\n}\n");
|
test!(preserves_keyword_nan, "a {\n color: NaN;\n}\n");
|
||||||
test!(
|
test!(
|
||||||
preserves_quotes,
|
preserves_quotes,
|
||||||
"a {\n color: \"'red' \\\"blue\\\"\";\n}\n"
|
"a {\n color: \"'foo' \\\"bar\\\"\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
whitespace_space_list_number,
|
whitespace_space_list_number,
|
||||||
@ -36,133 +36,133 @@ test!(
|
|||||||
test!(number, "a {\n color: 1;\n}\n");
|
test!(number, "a {\n color: 1;\n}\n");
|
||||||
test!(
|
test!(
|
||||||
removes_paren_around_single_value,
|
removes_paren_around_single_value,
|
||||||
"a {\n color: (red);\n}\n",
|
"a {\n color: (foo);\n}\n",
|
||||||
"a {\n color: red;\n}\n"
|
"a {\n color: foo;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
removes_paren_around_space_list,
|
removes_paren_around_space_list,
|
||||||
"a {\n color: (red blue);\n}\n",
|
"a {\n color: (foo bar);\n}\n",
|
||||||
"a {\n color: red blue;\n}\n"
|
"a {\n color: foo bar;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
removes_paren_around_item_in_list,
|
removes_paren_around_item_in_list,
|
||||||
"a {\n color: 1 (red blue);\n}\n",
|
"a {\n color: 1 (foo bar);\n}\n",
|
||||||
"a {\n color: 1 red blue;\n}\n"
|
"a {\n color: 1 foo bar;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_idents,
|
adds_idents,
|
||||||
"a {\n color: red + blue;\n}\n",
|
"a {\n color: foo + bar;\n}\n",
|
||||||
"a {\n color: redblue;\n}\n"
|
"a {\n color: foobar;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_dbl_quoted_idents,
|
adds_dbl_quoted_idents,
|
||||||
"a {\n color: \"red\" + \"blue\";\n}\n",
|
"a {\n color: \"foo\" + \"bar\";\n}\n",
|
||||||
"a {\n color: \"redblue\";\n}\n"
|
"a {\n color: \"foobar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_sgl_quoted_idents,
|
adds_sgl_quoted_idents,
|
||||||
"a {\n color: 'red' + 'blue';\n}\n",
|
"a {\n color: 'foo' + 'bar';\n}\n",
|
||||||
"a {\n color: \"redblue\";\n}\n"
|
"a {\n color: \"foobar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_dbl_and_un_quoted_idents,
|
adds_dbl_and_un_quoted_idents,
|
||||||
"a {\n color: \"red\" + blue;\n}\n",
|
"a {\n color: \"foo\" + bar;\n}\n",
|
||||||
"a {\n color: \"redblue\";\n}\n"
|
"a {\n color: \"foobar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_sgl_and_un_quoted_idents,
|
adds_sgl_and_un_quoted_idents,
|
||||||
"a {\n color: 'red' + blue;\n}\n",
|
"a {\n color: 'foo' + bar;\n}\n",
|
||||||
"a {\n color: \"redblue\";\n}\n"
|
"a {\n color: \"foobar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_un_and_dbl_quoted_idents,
|
adds_un_and_dbl_quoted_idents,
|
||||||
"a {\n color: red + \"blue\";\n}\n",
|
"a {\n color: foo + \"bar\";\n}\n",
|
||||||
"a {\n color: \"redblue\";\n}\n"
|
"a {\n color: \"foobar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_un_and_sgl_quoted_idents,
|
adds_un_and_sgl_quoted_idents,
|
||||||
"a {\n color: red + 'blue';\n}\n",
|
"a {\n color: foo + 'bar';\n}\n",
|
||||||
"a {\n color: \"redblue\";\n}\n"
|
"a {\n color: \"foobar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_sgl_and_dbl_quoted_idents,
|
adds_sgl_and_dbl_quoted_idents,
|
||||||
"a {\n color: 'red' + \"blue\";\n}\n",
|
"a {\n color: 'foo' + \"bar\";\n}\n",
|
||||||
"a {\n color: \"redblue\";\n}\n"
|
"a {\n color: \"foobar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_dbl_and_sgl_quoted_idents,
|
adds_dbl_and_sgl_quoted_idents,
|
||||||
"a {\n color: \"red\" + 'blue';\n}\n",
|
"a {\n color: \"foo\" + 'bar';\n}\n",
|
||||||
"a {\n color: \"redblue\";\n}\n"
|
"a {\n color: \"foobar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_ident_true,
|
adds_ident_true,
|
||||||
"a {\n color: red + true;\n}\n",
|
"a {\n color: foo + true;\n}\n",
|
||||||
"a {\n color: redtrue;\n}\n"
|
"a {\n color: footrue;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_dbl_quoted_ident_true,
|
adds_dbl_quoted_ident_true,
|
||||||
"a {\n color: \"red\" + true;\n}\n",
|
"a {\n color: \"foo\" + true;\n}\n",
|
||||||
"a {\n color: \"redtrue\";\n}\n"
|
"a {\n color: \"footrue\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_ident_false,
|
adds_ident_false,
|
||||||
"a {\n color: red + false;\n}\n",
|
"a {\n color: foo + false;\n}\n",
|
||||||
"a {\n color: redfalse;\n}\n"
|
"a {\n color: foofalse;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_dbl_quoted_ident_false,
|
adds_dbl_quoted_ident_false,
|
||||||
"a {\n color: \"red\" + false;\n}\n",
|
"a {\n color: \"foo\" + false;\n}\n",
|
||||||
"a {\n color: \"redfalse\";\n}\n"
|
"a {\n color: \"foofalse\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_ident_important,
|
adds_ident_important,
|
||||||
"a {\n color: red + !important;\n}\n",
|
"a {\n color: foo + !important;\n}\n",
|
||||||
"a {\n color: red!important;\n}\n"
|
"a {\n color: foo!important;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_ident_null,
|
adds_ident_null,
|
||||||
"a {\n color: red + null;\n}\n",
|
"a {\n color: foo + null;\n}\n",
|
||||||
"a {\n color: red;\n}\n"
|
"a {\n color: foo;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_dbl_quoted_ident_null,
|
adds_dbl_quoted_ident_null,
|
||||||
"a {\n color: \"red\" + null;\n}\n",
|
"a {\n color: \"foo\" + null;\n}\n",
|
||||||
"a {\n color: \"red\";\n}\n"
|
"a {\n color: \"foo\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_sgl_quoted_ident_null,
|
adds_sgl_quoted_ident_null,
|
||||||
"a {\n color: 'red' + null;\n}\n",
|
"a {\n color: 'foo' + null;\n}\n",
|
||||||
"a {\n color: \"red\";\n}\n"
|
"a {\n color: \"foo\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_ident_number,
|
adds_ident_number,
|
||||||
"a {\n color: red + 1;\n}\n",
|
"a {\n color: foo + 1;\n}\n",
|
||||||
"a {\n color: red1;\n}\n"
|
"a {\n color: foo1;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_dbl_quoted_ident_number,
|
adds_dbl_quoted_ident_number,
|
||||||
"a {\n color: \"red\" + 1;\n}\n",
|
"a {\n color: \"foo\" + 1;\n}\n",
|
||||||
"a {\n color: \"red1\";\n}\n"
|
"a {\n color: \"foo1\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_sgl_quoted_ident_number,
|
adds_sgl_quoted_ident_number,
|
||||||
"a {\n color: 'red' + 1;\n}\n",
|
"a {\n color: 'foo' + 1;\n}\n",
|
||||||
"a {\n color: \"red1\";\n}\n"
|
"a {\n color: \"foo1\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_ident_dimension,
|
adds_ident_dimension,
|
||||||
"a {\n color: red + 1px;\n}\n",
|
"a {\n color: foo + 1px;\n}\n",
|
||||||
"a {\n color: red1px;\n}\n"
|
"a {\n color: foo1px;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_dbl_quoted_ident_dimension,
|
adds_dbl_quoted_ident_dimension,
|
||||||
"a {\n color: \"red\" + 1px;\n}\n",
|
"a {\n color: \"foo\" + 1px;\n}\n",
|
||||||
"a {\n color: \"red1px\";\n}\n"
|
"a {\n color: \"foo1px\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_sgl_quoted_ident_dimension,
|
adds_sgl_quoted_ident_dimension,
|
||||||
"a {\n color: 'red' + 1px;\n}\n",
|
"a {\n color: 'foo' + 1px;\n}\n",
|
||||||
"a {\n color: \"red1px\";\n}\n"
|
"a {\n color: \"foo1px\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
adds_true_false,
|
adds_true_false,
|
||||||
@ -181,116 +181,116 @@ test!(
|
|||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_idents,
|
subs_idents,
|
||||||
"a {\n color: red - blue;\n}\n",
|
"a {\n color: foo - bar;\n}\n",
|
||||||
"a {\n color: red-blue;\n}\n"
|
"a {\n color: foo-bar;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_dbl_quoted_idents,
|
subs_dbl_quoted_idents,
|
||||||
"a {\n color: \"red\" - \"blue\";\n}\n",
|
"a {\n color: \"foo\" - \"bar\";\n}\n",
|
||||||
"a {\n color: \"red\"-\"blue\";\n}\n"
|
"a {\n color: \"foo\"-\"bar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_sgl_quoted_idents,
|
subs_sgl_quoted_idents,
|
||||||
"a {\n color: 'red' - 'blue';\n}\n",
|
"a {\n color: 'foo' - 'bar';\n}\n",
|
||||||
"a {\n color: \"red\"-\"blue\";\n}\n"
|
"a {\n color: \"foo\"-\"bar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_dbl_and_un_quoted_idents,
|
subs_dbl_and_un_quoted_idents,
|
||||||
"a {\n color: \"red\" - blue;\n}\n",
|
"a {\n color: \"foo\" - bar;\n}\n",
|
||||||
"a {\n color: \"red\"-blue;\n}\n"
|
"a {\n color: \"foo\"-bar;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_sgl_and_un_quoted_idents,
|
subs_sgl_and_un_quoted_idents,
|
||||||
"a {\n color: 'red' - blue;\n}\n",
|
"a {\n color: 'foo' - bar;\n}\n",
|
||||||
"a {\n color: \"red\"-blue;\n}\n"
|
"a {\n color: \"foo\"-bar;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_un_and_dbl_quoted_idents,
|
subs_un_and_dbl_quoted_idents,
|
||||||
"a {\n color: red - \"blue\";\n}\n",
|
"a {\n color: foo - \"bar\";\n}\n",
|
||||||
"a {\n color: red-\"blue\";\n}\n"
|
"a {\n color: foo-\"bar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_un_and_sgl_quoted_idents,
|
subs_un_and_sgl_quoted_idents,
|
||||||
"a {\n color: red - 'blue';\n}\n",
|
"a {\n color: foo - 'bar';\n}\n",
|
||||||
"a {\n color: red-\"blue\";\n}\n"
|
"a {\n color: foo-\"bar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_sgl_and_dbl_quoted_idents,
|
subs_sgl_and_dbl_quoted_idents,
|
||||||
"a {\n color: 'red' - \"blue\";\n}\n",
|
"a {\n color: 'foo' - \"bar\";\n}\n",
|
||||||
"a {\n color: \"red\"-\"blue\";\n}\n"
|
"a {\n color: \"foo\"-\"bar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_dbl_and_sgl_quoted_idents,
|
subs_dbl_and_sgl_quoted_idents,
|
||||||
"a {\n color: \"red\" - 'blue';\n}\n",
|
"a {\n color: \"foo\" - 'bar';\n}\n",
|
||||||
"a {\n color: \"red\"-\"blue\";\n}\n"
|
"a {\n color: \"foo\"-\"bar\";\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_ident_true,
|
subs_ident_true,
|
||||||
"a {\n color: red - true;\n}\n",
|
"a {\n color: foo - true;\n}\n",
|
||||||
"a {\n color: red-true;\n}\n"
|
"a {\n color: foo-true;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_dbl_quoted_ident_true,
|
subs_dbl_quoted_ident_true,
|
||||||
"a {\n color: \"red\" - true;\n}\n",
|
"a {\n color: \"foo\" - true;\n}\n",
|
||||||
"a {\n color: \"red\"-true;\n}\n"
|
"a {\n color: \"foo\"-true;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_ident_false,
|
subs_ident_false,
|
||||||
"a {\n color: red - false;\n}\n",
|
"a {\n color: foo - false;\n}\n",
|
||||||
"a {\n color: red-false;\n}\n"
|
"a {\n color: foo-false;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_dbl_quoted_ident_false,
|
subs_dbl_quoted_ident_false,
|
||||||
"a {\n color: \"red\" - false;\n}\n",
|
"a {\n color: \"foo\" - false;\n}\n",
|
||||||
"a {\n color: \"red\"-false;\n}\n"
|
"a {\n color: \"foo\"-false;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_ident_important,
|
subs_ident_important,
|
||||||
"a {\n color: red - !important;\n}\n",
|
"a {\n color: foo - !important;\n}\n",
|
||||||
"a {\n color: red-!important;\n}\n"
|
"a {\n color: foo-!important;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_ident_null,
|
subs_ident_null,
|
||||||
"a {\n color: red - null;\n}\n",
|
"a {\n color: foo - null;\n}\n",
|
||||||
"a {\n color: red-;\n}\n"
|
"a {\n color: foo-;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_dbl_quoted_ident_null,
|
subs_dbl_quoted_ident_null,
|
||||||
"a {\n color: \"red\" - null;\n}\n",
|
"a {\n color: \"foo\" - null;\n}\n",
|
||||||
"a {\n color: \"red\"-;\n}\n"
|
"a {\n color: \"foo\"-;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_sgl_quoted_ident_null,
|
subs_sgl_quoted_ident_null,
|
||||||
"a {\n color: 'red' - null;\n}\n",
|
"a {\n color: 'foo' - null;\n}\n",
|
||||||
"a {\n color: \"red\"-;\n}\n"
|
"a {\n color: \"foo\"-;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_ident_number,
|
subs_ident_number,
|
||||||
"a {\n color: red - 1;\n}\n",
|
"a {\n color: foo - 1;\n}\n",
|
||||||
"a {\n color: red-1;\n}\n"
|
"a {\n color: foo-1;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_dbl_quoted_ident_number,
|
subs_dbl_quoted_ident_number,
|
||||||
"a {\n color: \"red\" - 1;\n}\n",
|
"a {\n color: \"foo\" - 1;\n}\n",
|
||||||
"a {\n color: \"red\"-1;\n}\n"
|
"a {\n color: \"foo\"-1;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_sgl_quoted_ident_number,
|
subs_sgl_quoted_ident_number,
|
||||||
"a {\n color: 'red' - 1;\n}\n",
|
"a {\n color: 'foo' - 1;\n}\n",
|
||||||
"a {\n color: \"red\"-1;\n}\n"
|
"a {\n color: \"foo\"-1;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_ident_dimension,
|
subs_ident_dimension,
|
||||||
"a {\n color: red - 1px;\n}\n",
|
"a {\n color: foo - 1px;\n}\n",
|
||||||
"a {\n color: red-1px;\n}\n"
|
"a {\n color: foo-1px;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_dbl_quoted_ident_dimension,
|
subs_dbl_quoted_ident_dimension,
|
||||||
"a {\n color: \"red\" - 1px;\n}\n",
|
"a {\n color: \"foo\" - 1px;\n}\n",
|
||||||
"a {\n color: \"red\"-1px;\n}\n"
|
"a {\n color: \"foo\"-1px;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
subs_sgl_quoted_ident_dimension,
|
subs_sgl_quoted_ident_dimension,
|
||||||
"a {\n color: 'red' - 1px;\n}\n",
|
"a {\n color: 'foo' - 1px;\n}\n",
|
||||||
"a {\n color: \"red\"-1px;\n}\n"
|
"a {\n color: \"foo\"-1px;\n}\n"
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user