Skip to main content

jsonld_word_count

Function jsonld_word_count 

Source
pub fn jsonld_word_count(html: &str) -> Option<u64>
Expand description

Lifts wordCount from any <script type="application/ld+json"> block in the page (BlogPosting / Article emit it in the Python original this port mirrors).

ยงExamples

use ssg::agent_api::jsonld_word_count;
let html = r#"<script type="application/ld+json">
  {"@type":"BlogPosting","wordCount":321}
</script>"#;
assert_eq!(jsonld_word_count(html), Some(321));
assert_eq!(jsonld_word_count("<p>no jsonld</p>"), None);