Skip to main content

parse_author

Function parse_author 

Source
pub fn parse_author(raw: &str) -> (Option<String>, Option<String>)
Expand description

Parses email (Name) and Name <email> author conventions.

ยงExamples

use ssg::agent_api::parse_author;
let (name, email) = parse_author("[email protected] (Jane Doe)");
assert_eq!(name.as_deref(), Some("Jane Doe"));
assert_eq!(email.as_deref(), Some("[email protected]"));

let (name, email) = parse_author("Jane Doe <[email protected]>");
assert_eq!(name.as_deref(), Some("Jane Doe"));
assert_eq!(email.as_deref(), Some("[email protected]"));

let (name, email) = parse_author("Jane Doe");
assert_eq!(name.as_deref(), Some("Jane Doe"));
assert!(email.is_none());