Skip to main content

parsec/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 James Conway
3
4//! Parsec: an HTML parser that follows the WHATWG HTML Standard, with CSS
5//! selectors and a tree you can change and write back out, and the other
6//! standards a page needs beside it.
7//!
8//! The parser is at the top of this crate, and each standard is a module
9//! behind a cargo feature:
10//!
11//! | Module | Feature | Default |
12//! |---|---|---|
13//! | `encoding` | `encoding` | on |
14//! | `url` | `url` | on |
15//! | `xpath` | `xpath` | on |
16//! | `stylesheet` | `css` | off |
17//!
18//! [`css`] is the selector engine, which is always here; `stylesheet` is
19//! CSS Syntax and the cascade, which a scraper rarely needs.
20//!
21//! ```
22//! use parsec::css::SelectorList;
23//!
24//! let doc = parsec::parse("<ul><li class=hit>one<li>two</ul>", false);
25//! let hits = SelectorList::parse("li.hit").unwrap().select(&doc, doc.root());
26//! assert_eq!(doc.text(hits[0]), "one");
27//! ```
28
29#[doc(inline)]
30pub use html::*;
31
32#[cfg(feature = "encoding")]
33#[doc(inline)]
34pub use parsec_encoding as encoding;
35
36#[cfg(feature = "url")]
37#[doc(inline)]
38pub use parsec_url as url;
39
40#[cfg(feature = "xpath")]
41#[doc(inline)]
42pub use parsec_xpath as xpath;
43
44#[cfg(feature = "css")]
45#[doc(inline)]
46pub use parsec_css as stylesheet;