use lazy_static::lazy_static;
use onig::*;
lazy_static! {
pub static ref PREFIXED_SELECTORS: Regex = Regex::new(
r##"(?x)
(?:
(?<type>[\#\.]?)
__
(?<context>
(?:class | id | ignore)?
)
--
)
(?<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 INTERNAL_ANCHOR_TARGET_ID: Regex = Regex::new(
r##"(?x)
^(?>http:|https:)?\/{2}.*$
| ^[^#]*[#]__(?:class | id | ignore)?--
| ^(?<url>[^#]*)
(?<target_id>\#[^#]*)$
"##
).unwrap();
pub static ref STRING_DELIMITED_BY_SPACE: Regex = Regex::new(
r##"(?x)
(?<token>
(?>
\\[0-9A-Fa-f]{1,6}(?>\r\n|[ \n\r\t\f])?
| \\[^\n\r\f0-9A-Fa-f]
| [^\s]
)+
)
"##
).unwrap();
pub static ref STRING_DELIMITED_BY_COMMA: Regex = Regex::new(
r##"(?x)
(?<token>
(?<token_delimiter>["'`])
(?<token_string>
(?:
(?<=")
(?:[^"\\] | \\.)*
)
| (?:
(?<=')
(?:[^'\\] | \\.)*
)
| (?:
(?<=`)
(?:[^`\\] | \\.)*
)
)
["'`]
)
| (?<expression>
(?:
!*
(?:
(?:
\.?
[$\w]+
)
| (?:
\(
(?: [^()] | \k<expression>)*
\)
)
)+
(?:
\s*
(?:
&&
| \|\|
| \?{1,2}
| :
| ={1,3}
| !={1,2}
| >={0,2}
| <={0,2}
| ["'`]
(?:
(?:(?<=")[^"]*)
| (?:(?<=')[^']*)
| (?:(?<=`)[^`]*)
)
["'`]
)
\s*
)*
)+
)
| (?<object>
\{
(?: [^{}] | \k<object> )*
\}
)
| (?<array>
\[
(?: [^\[\]] | \k<array> )*
\]
)
"##
).unwrap();
}