(html: &str)
| 1305 | } |
| 1306 | |
| 1307 | fn extract_description_from_html(html: &str) -> Option<String> { |
| 1308 | if let Some(prose_index) = html.find("class=\"prose") { |
| 1309 | let scope = &html[prose_index..]; |
| 1310 | if let Some(p_start) = scope.find("<p>") { |
| 1311 | let content = &scope[p_start + 3..]; |
| 1312 | if let Some(p_end) = content.find("</p>") { |
| 1313 | let raw = &content[..p_end]; |
| 1314 | let normalized = normalize_html_text(raw); |
| 1315 | if !normalized.is_empty() { |
| 1316 | return Some(limit_text_len(&normalized, MARKET_DESC_MAX_LEN)); |
| 1317 | } |
| 1318 | } |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | if let Some(twitter_desc) = extract_meta_content(html, "twitter:description") { |
| 1323 | let normalized = normalize_html_text(&twitter_desc); |
| 1324 | if is_meaningful_meta_description(&normalized) { |
| 1325 | return Some(limit_text_len(&normalized, MARKET_DESC_MAX_LEN)); |
| 1326 | } |
| 1327 | } |
| 1328 | |
| 1329 | None |
| 1330 | } |
| 1331 | |
| 1332 | fn extract_meta_content(html: &str, key: &str) -> Option<String> { |
| 1333 | let pattern = format!(r#"<meta name="{}" content="([^"]+)""#, regex::escape(key)); |
no test coverage detected