Skip to main content

extract_title

Function extract_title 

Source
pub fn extract_title(html: &str) -> String
Expand description

Extract the page title from the <title> tag.

Backed by extract_head_meta so a comment containing <!-- <title>…</title> --> no longer fools the extractor and quoting / attribute-order variants on <title> (extremely rare but legal) are handled by the parser.

§Examples

use ssg::seo::helpers::extract_title;

let html = "<html><head><title>Hello</title></head></html>";
assert_eq!(extract_title(html), "Hello");