Skip to main content

md_link_target

Function md_link_target 

Source
pub fn md_link_target(url: &str) -> String
Expand description

The resolution target of a markdown link’s URL: percent-decoded, minus its trailing .md.

Public alongside is_vault_link_url, and pinned rather than tidied. The trim_end_matches pair strips repeatedly, so a.md.md targets a rather than a.md. That is the long-standing behaviour, so indexes built with it stay valid. strip_md_ext is the single-strip, case-insensitive fallback for the mixed-case spellings the pair does not catch.

§Examples

use markdown_link::md_link_target;

assert_eq!(md_link_target("My%20Note.md"), "My Note");
assert_eq!(md_link_target("a.md.md"), "a");
assert_eq!(md_link_target("a.Md"), "a");
assert_eq!(md_link_target("img.png"), "img.png");