pub const VALID_HTML_ELEMENTS: &[&str] = &[
"a", "abbr", "address", "area", "article", "aside", "audio",
"b", "base", "bdi", "bdo", "blockquote", "body", "br", "button",
"canvas", "caption", "cite", "code", "col", "colgroup",
"data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt",
"em", "embed",
"fieldset", "figcaption", "figure", "footer", "form",
"h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html",
"i", "iframe", "img", "input", "ins",
"kbd",
"label", "legend", "li", "link",
"main", "map", "mark", "math", "menu", "meta", "meter",
"nav", "noscript",
"object", "ol", "optgroup", "option", "output",
"p", "param", "picture", "portal", "pre", "progress",
"q",
"rp", "rt", "ruby",
"s", "samp", "script", "section", "select", "slot", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "svg",
"table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track",
"u", "ul",
"var", "video",
"wbr"
];
pub const VALID_PSEUDO_CLASSES: &[&str] = &[
"active", "any-link",
"checked",
"default", "disabled",
"empty", "enabled",
"first-child", "first-of-type", "focus", "focus-visible", "focus-within",
"has", "hover",
"in-range", "indeterminate", "invalid", "is",
"last-child", "last-of-type", "link",
"not", "nth-child", "nth-last-child", "nth-last-of-type", "nth-of-type",
"only-child", "only-of-type", "optional", "out-of-range",
"placeholder-shown",
"read-only", "read-write", "required", "root",
"scope",
"target",
"valid", "visited",
"where"
];
pub const SCSS_KEYWORDS: &[&str] = &[
"@mixin", "@include", "@import", "@use", "@forward", "@extend",
"@function", "@return", "@if", "@else", "@each", "@for", "@while",
"@at-root", "@error", "@warn", "@debug",
];
pub const SCSS_VARIABLE_PREFIX: char = '$';
pub const SCSS_PARENT_REF: char = '&';
#[inline]
pub fn is_valid_html_element(name: &str) -> bool {
VALID_HTML_ELEMENTS.binary_search(&name).is_ok()
}
#[inline]
pub fn is_valid_pseudo_class(name: &str) -> bool {
VALID_PSEUDO_CLASSES.binary_search(&name).is_ok()
}
#[inline]
pub fn looks_like_scss(content: &str) -> bool {
if content.contains(SCSS_VARIABLE_PREFIX) {
return true;
}
if content.contains(SCSS_PARENT_REF) {
return true;
}
for keyword in SCSS_KEYWORDS {
if content.contains(keyword) {
return true;
}
}
false
}