Skip to main content

parse

Function parse 

Source
pub fn parse(value: &str) -> Result<Font, ParseError>
Expand description

Parse a CSS font shorthand value.

ยงErrors

Returns ParseError for an empty string, a value missing the required font-size or font-family, or a property specified more than once.

use parse_css_font::{parse, Font};
assert!(matches!(parse("12px serif"), Ok(Font::Shorthand(_))));
assert!(parse("12px").is_err()); // no family