Skip to main content

parse_typed_ref

Function parse_typed_ref 

Source
pub fn parse_typed_ref(value: &str) -> Option<TypedRef>
Expand description

Parse a whole value as a typed reference, or None.

Shape only: the target is not resolved. The value is exactly [[...]] with no [, ] or line break inside. The target ends at the first |, minus a \ that escapes it, as in parse_inner. Its type and each /-separated slug segment are non-empty and hold no whitespace.

ยงExamples

use markdown_link::parse_typed_ref;

assert_eq!(parse_typed_ref("[[a/b/c]]").unwrap().slug, "b/c");
assert!(parse_typed_ref("[[no-slash]]").is_none());
assert!(parse_typed_ref("[[a/b]] trailing").is_none());
assert!(parse_typed_ref("[[a/has space]]").is_none());