Skip to main content

scraper/
lib.rs

1#![doc = include_str!("../README.md")]
2#![warn(
3    missing_docs,
4    missing_debug_implementations,
5    missing_copy_implementations,
6    trivial_casts,
7    trivial_numeric_casts,
8    unused_extern_crates,
9    unused_import_braces,
10    unused_qualifications,
11    variant_size_differences
12)]
13
14#[macro_use]
15extern crate html5ever;
16
17pub use crate::element_ref::ElementRef;
18pub use crate::html::{Html, HtmlTreeSink};
19pub use crate::node::Node;
20pub use crate::selector::Selector;
21
22pub use selectors::{Element, attr::CaseSensitivity};
23
24pub mod element_ref;
25pub mod error;
26pub mod html;
27pub mod node;
28pub mod selectable;
29pub mod selector;
30
31#[cfg(feature = "atomic")]
32pub(crate) mod tendril_util {
33    use html5ever::tendril;
34    /// Atomic equivalent to the default `StrTendril` type.
35    pub type StrTendril = tendril::Tendril<tendril::fmt::UTF8, tendril::Atomic>;
36
37    /// Convert a standard tendril into an atomic one.
38    pub fn make(s: tendril::StrTendril) -> StrTendril {
39        s.into_send().into()
40    }
41}
42
43#[cfg(not(feature = "atomic"))]
44pub(crate) mod tendril_util {
45    use html5ever::tendril;
46    /// Primary string tendril type.
47    pub type StrTendril = tendril::StrTendril;
48
49    /// Return unaltered.
50    pub fn make(s: StrTendril) -> StrTendril {
51        s
52    }
53}
54
55pub use tendril_util::StrTendril;
56
57#[cfg(test)]
58mod test;