Function goose_eggs::get_html_header
source · pub fn get_html_header(html: &str) -> Option<String>
Expand description
Use a regular expression to get the HTML header from the web page.
Example
use goose_eggs::get_html_header;
// For this example we grab just a subset of a web page, enough to demonstrate. Normally
// you'd use the entire html snippet returned from [`validate_page`] or
// [`validate_and_load_static_assets`].
let html = r#"
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<link rel="canonical" href="https://example.com/" />
<link rel="shortlink" href="https://example.com/" />
<meta name="Generator" content="Drupal 9 (https://www.drupal.org)" />
<meta name="MobileOptimized" content="width" />
<meta name="HandheldFriendly" content="true" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Example Website</title>
</head>
<body>
This is the web page body.
</body>
</html>
"#;
let html_header = get_html_header(html);
assert!(!html_header.is_none());