#![doc = include_str!("../README.md")]
#![deny(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "portable-simd", feature(portable_simd))]
mod bytes;
pub mod errors;
pub mod inline;
mod parser;
pub mod queryselector;
mod stream;
#[cfg(all(test, feature = "std"))]
mod tests;
mod util;
mod vdom;
#[doc(hidden)]
#[cfg(feature = "__INTERNALS_DO_NOT_USE")]
pub mod simd;
#[cfg(not(feature = "__INTERNALS_DO_NOT_USE"))]
mod simd;
pub use bytes::Bytes;
pub use errors::ParseError;
pub use parser::*;
use queryselector::Selector;
pub use vdom::VDom;
#[cfg(feature = "std")]
pub use vdom::VDomGuard;
#[cfg(feature = "std")]
const STD_INLINE_CLASS_HANDLES: usize = 32;
#[cfg(feature = "std")]
const STD_INLINE_IDS: usize = 16;
#[cfg(feature = "std")]
const STD_INLINE_CLASSES: usize = 16;
#[cfg(feature = "std")]
pub fn parse(
input: &str,
options: ParserOptions,
) -> Result<
VDom<'_, STD_INLINE_CLASS_HANDLES, 0, 0, STD_INLINE_IDS, STD_INLINE_CLASSES, 0>,
ParseError,
> {
let mut parser =
Parser::<STD_INLINE_CLASS_HANDLES, 0, 0, STD_INLINE_IDS, STD_INLINE_CLASSES, 0>::new(
input, options,
);
parser.parse()?;
Ok(VDom::from(parser))
}
#[cfg(not(feature = "std"))]
pub fn parse<
const MAX_NODES: usize,
const MAX_STACK: usize,
const MAX_ROOTS: usize,
const MAX_IDS: usize,
const MAX_CLASSES: usize,
const MAX_SELECTOR_NODES: usize,
>(
input: &str,
options: ParserOptions,
) -> Result<
VDom<'_, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>,
ParseError,
> {
let mut parser = Parser::new(input, options);
parser.parse()?;
Ok(VDom::from(parser))
}
#[cfg(feature = "std")]
pub fn parse_query_selector(input: &str) -> Option<Selector<'_>> {
let selector = queryselector::Parser::new(input.as_bytes()).selector()?;
Some(selector)
}
#[cfg(not(feature = "std"))]
pub fn parse_query_selector<const MAX_SELECTOR_NODES: usize>(
input: &str,
) -> Result<Selector<'_, MAX_SELECTOR_NODES>, ParseError> {
queryselector::Parser::new(input.as_bytes()).selector::<MAX_SELECTOR_NODES>()
}
#[cfg(feature = "std")]
pub unsafe fn parse_owned(input: String, options: ParserOptions) -> Result<VDomGuard, ParseError> {
VDomGuard::parse(input, options)
}