use lazy_static::lazy_static;
use onig::*;
lazy_static! {
pub static ref CSS_SELECTORS: Regex = Regex::new(
r##"(?x)
{[^{}]*}
| \[
\s*
["']?.*?["']?
\s*
\]
| \/\*[^*]*\*+(?>[^\/*][^*]*\*+)*\/
| @import\s++(?:
url\([^)]*\)
| (?:"(?:[^"])*")
| (?:'(?:[^'])*')
)
| [\#\.]?__(?:class | id | ignore)?--
| (?<type>[\#\.])
(?<name>
-?
(?>
[A-Za-z_]
| [^\0-\177]
| (?>
\\[0-9A-Fa-f]{1,6}(?>\r\n|[ \n\r\t\f])?
| \\[^\n\r\f0-9A-Fa-f]
)
)
(?>
[\w\-]
| [^\0-\177]
| (?>
\\[0-9A-Fa-f]{1,6}(?>\r\n|[ \n\r\t\f])?
| \\[^\n\r\f0-9A-Fa-f]
)
)*
)
"##
).unwrap();
pub static ref CSS_ATTRIBUTES: Regex = Regex::new(
r##"(?x)
\/\*[^*]*\*+(?>[^\/*][^*]*\*+)*\/
| \[\s*+
(?<attribute>
(?>
[^\f\n\t\ \\>"'|:^$*~=]
| (?>
\\[0-9A-Fa-f]{1,6}(?>\r\n|[ \n\r\t\f])?
| \\[^\n\r\f0-9A-Fa-f]
)
)++
)
\s*+
(?<operator>
[~]?=
)
\s*+
(?<quote>
(?:\\?["'])?
)
(?<value>
(?:
(?<=["'])
(?:
[^"'\\]
| (?>
\\[0-9A-Fa-f]{1,6}(?>\r\n|[ \n\r\t\f])?
| \\[^\n\r\f0-9A-Fa-f"']
)
)*
)
| (?:
-?
(?>
[A-Za-z_]
| [^\0-\177]
| (?>
\\[0-9A-Fa-f]{1,6}(?>\r\n|[ \n\r\t\f])?
| \\[^\n\r\f0-9A-Fa-f]
)
)
(?>
[\w\-]
| [^\0-\177]
| (?>
\\[0-9A-Fa-f]{1,6}(?>\r\n|[ \n\r\t\f])?
| \\[^\n\r\f0-9A-Fa-f]
)
)*
)
)
(?>\\?["'])?
(?<spacer>\s*+)
(?<flag>[IiSs]?)
\s*+\]
"##
).unwrap();
pub static ref CSS_FUNCTIONS: Regex = Regex::new(
r##"(?x)
(?<function>
url
)
(?<join>
\(\s*+
)
(?<quote>
(?:\\?["'])?
)
(?<argument>
(?:
(?<=")(?:[^"])*
)
| (?:
(?<=')(?:[^'])*
)
| (?:
[^\s\)]*
)
)
"##
).unwrap();
pub static ref ESCAPED_CSS_CHARS: Regex = Regex::new(
r##"(?x)
(?<unicode>
\\[0-9A-Fa-f]{1,6}(?>\r\n|[ \n\r\t\f])?
)
| (?<character>
\\[^\n\r\f0-9A-Fa-f]
)
"##
).unwrap();
pub static ref INVALID_CSS_CHARACTERS: Regex = Regex::new(
r##"(?x)
[\0-\54\56\57\72-\100\133-\136\140\173-\177]
"##
).unwrap();
}