pub fn extract_head_meta(html: &str) -> HeadMetaExpand description
Extracts {title, lang, canonical} from html in a single
lol_html pass.
titleis the text content of the first<title>element with inner tags stripped (matching the historicalextract_titlebehaviour). Whitespace is collapsed and trimmed; returns the empty string when the element is missing or its text content is whitespace-only.langis thelangattribute on the root<html>element.<html lang="…">inside a<pre>block is ignored becauselol_htmlonly matches the real element.canonicalis thehrefattribute of the first<link rel~="canonical">in<head>. Selector matches the space-separated token set sorel="canonical other-token"is detected, while quoting style is irrelevant (the parser normalises it).
§Examples
use ssg::util::head_dom::extract_head_meta;
let html = r#"<html lang="en"><head><title>Hi</title></head></html>"#;
let meta = extract_head_meta(html);
assert_eq!(meta.title, "Hi");
assert_eq!(meta.lang, "en");