Skip to main content

parse_reference_definitions

Function parse_reference_definitions 

Source
pub fn parse_reference_definitions(content: &str) -> Vec<ReferenceDefinition>
Expand description

Parse the reference definitions ([label]: destination) that reference links in content take their destinations from. The links themselves, [text][label], [label][] and [label], are among parse_markdown_links, with the definition’s destination as target.

§Example

use turbovault_parser::parse_reference_definitions;

let content = "See [the paper][p].\n\n[p]: papers/My%20Paper.md \"Title\"\n";
let definitions = parse_reference_definitions(content);
assert_eq!(definitions[0].target, "papers/My Paper.md");
assert_eq!(&content[definitions[0].destination.clone()], "papers/My%20Paper.md");