html_validation/
valid_tags.rs

1use lazy_static::lazy_static;
2use std::collections::hash_set::HashSet;
3
4use super::svg_namespace::is_svg_namespace;
5
6lazy_static! {
7    static ref VALID_TAGS: HashSet<&'static str> = [
8        "a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big",
9        "blockquote","body","br","button","canvas","caption","cite","code","col","colgroup",
10        "command", "data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed",
11        "fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head",
12        "header","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend",
13        "li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object",
14        "ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt",
15        "ruby","s","samp","script","section","select","small","source","span","strong","style",
16        "sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title",
17        "tr","track","u","ul","var","video","wbr",
18    ]
19    .iter()
20    .cloned()
21    .collect();
22}
23
24/// Whether or not this tag is valid
25///
26/// ```
27/// use html_validation::is_valid_tag;
28///
29/// assert_eq!(is_valid_tag("br"), true);
30///
31/// assert_eq!(is_valid_tag("random"), false);
32/// ```
33pub fn is_valid_tag(tag: &str) -> bool {
34    VALID_TAGS.contains(tag) || is_svg_namespace(tag)
35}