Skip to main content

display_text

Function display_text 

Source
pub fn display_text(text: &str) -> String
Expand description

Replace each wikilink and embed with what a reader sees for it, for snippets and search: its alias, or else its target. An embed’s trailing |300 or |300x200 is a size, not an alias, so ![[img.png|300]] shows img.png. An empty alias shows the target. Code is not skipped.

§Examples

use markdown_link::display_text;

assert_eq!(display_text("See [[Note#h|the note]]."), "See the note.");
assert_eq!(display_text("[[Note]] and ![[img.png|300]]"), "Note and img.png");
assert_eq!(display_text("[[Note|]]"), "Note"); // empty alias shows the target