pub fn parse_bytes(input: &[u8]) -> Result<Document, HtmlError>Expand description
Parse raw bytes into a Document, auto-detecting the encoding.
The encoding detection pipeline:
- BOM detection (UTF-8, UTF-16 LE/BE)
<meta charset="...">prescan (first 1 KB)<meta http-equiv="Content-Type" content="...charset=...">prescan- Fallback to UTF-8
§Errors
Returns HtmlError::InputTooLarge if the input exceeds 256 MiB, or
HtmlError::Encoding if the detected encoding cannot decode the input.
§Example
use fhp_tree::parse_bytes;
let doc = parse_bytes(b"<div>Hello</div>").unwrap();
let root = doc.root();
assert_eq!(root.text_content(), "Hello");