pub trait Parser: Sealed {
// Required method
fn parse_with_config(
&self,
html: &str,
config: &ParseConfig,
) -> ParseResult<Document>;
// Provided method
fn parse(&self, html: &str) -> ParseResult<Document> { ... }
}Expand description
A sealed trait for HTML parsers.
This trait is sealed and cannot be implemented outside of this crate.
Use Html5everParser for spec-compliant HTML5 parsing.
§Example
ⓘ
use scrape_core::{Html5everParser, Parser, ParseConfig};
let parser = Html5everParser;
let document = parser.parse("<html><body>Hello</body></html>")?;Required Methods§
Sourcefn parse_with_config(
&self,
html: &str,
config: &ParseConfig,
) -> ParseResult<Document>
fn parse_with_config( &self, html: &str, config: &ParseConfig, ) -> ParseResult<Document>
Parses HTML with the given configuration.
§Errors
Returns ParseError if parsing fails:
ParseError::EmptyInputif the input is empty or whitespace-onlyParseError::MaxDepthExceededif nesting exceedsconfig.max_depth
Provided Methods§
Sourcefn parse(&self, html: &str) -> ParseResult<Document>
fn parse(&self, html: &str) -> ParseResult<Document>
Parses HTML with default configuration.
§Errors
Returns ParseError::EmptyInput if the input is empty or whitespace-only.