use dom_query::Matcher;
use once_cell::sync::Lazy;
pub static SELECTORS: Lazy<Selectors> = Lazy::new(Selectors::new);
#[derive(Clone)]
pub struct Selectors {
pub body: Matcher,
pub html: Matcher,
pub title: Matcher,
pub meta: Matcher,
pub p: Matcher,
pub a: Matcher,
pub br: Matcher,
pub hr: Matcher,
pub h1: Matcher,
pub h1_h2: Matcher,
pub img: Matcher,
pub li: Matcher,
pub table: Matcher,
pub ul_ol: Matcher,
pub object_embed_iframe: Matcher,
pub script_noscript: Matcher,
pub style: Matcher,
pub font: Matcher,
pub noscript: Matcher,
pub caption: Matcher,
pub itemprop: Matcher,
pub img_picture_figure: Matcher,
pub img_picture: Matcher,
pub img_embed_object_iframe: Matcher,
pub img_picture_figure_video_audio_source: Matcher,
pub table_data_elements: Matcher,
pub json_ld_script: Matcher,
pub headings: Matcher,
pub textish_tags: Matcher,
pub p_pre_article: Matcher,
pub div_br: Matcher,
}
impl Selectors {
pub fn new() -> Self {
Self {
body: Matcher::new("body").unwrap(),
html: Matcher::new("html").unwrap(),
title: Matcher::new("title").unwrap(),
meta: Matcher::new("meta").unwrap(),
p: Matcher::new("p").unwrap(),
a: Matcher::new("a").unwrap(),
br: Matcher::new("br").unwrap(),
hr: Matcher::new("hr").unwrap(),
h1: Matcher::new("h1").unwrap(),
h1_h2: Matcher::new("h1, h2").unwrap(),
img: Matcher::new("img").unwrap(),
li: Matcher::new("li").unwrap(),
table: Matcher::new("table").unwrap(),
ul_ol: Matcher::new("ul, ol").unwrap(),
object_embed_iframe: Matcher::new("object, embed, iframe").unwrap(),
script_noscript: Matcher::new("script, noscript").unwrap(),
style: Matcher::new("style").unwrap(),
font: Matcher::new("font").unwrap(),
noscript: Matcher::new("noscript").unwrap(),
caption: Matcher::new("caption").unwrap(),
itemprop: Matcher::new("[itemprop*='name']").unwrap(),
img_picture_figure: Matcher::new("img, picture, figure").unwrap(),
img_picture: Matcher::new("img, picture").unwrap(),
img_embed_object_iframe: Matcher::new("img, embed, object, iframe").unwrap(),
img_picture_figure_video_audio_source: Matcher::new(
"img, picture, figure, video, audio, source",
)
.unwrap(),
table_data_elements: Matcher::new("col, colgroup, tfoot, thead, th").unwrap(),
json_ld_script: Matcher::new("script[type='application/ld+json']").unwrap(),
headings: Matcher::new("h1, h2, h3, h4, h5, h6").unwrap(),
textish_tags: Matcher::new(
"span, li, td, blockquote, dl, div, img, ol, p, pre, table, ul",
)
.unwrap(),
p_pre_article: Matcher::new("p, pre, article").unwrap(),
div_br: Matcher::new("div > br").unwrap(),
}
}
}
impl Default for Selectors {
fn default() -> Self {
Self::new()
}
}