Skip to main content

parse

Function parse 

Source
pub fn parse(md: &str, base: Font) -> (String, Vec<TextRun>)
Expand description

Parse inline markdown into the plain text a label shows plus the runs that style it.

Recognized:

MarkdownRun
**bold**, __bold__bold
*italic*, _italic_italic
`code`the monospaced face
~~strike~~struck through
[text](url)a link run
\*the literal character

base is the font the styles vary from. Pass the label’s font, so a bold run inside a Footnote paragraph stays footnote-sized.

Anything unrecognized is text: an unclosed **, a stray _ inside a word, a [ with no ](…) after it. Markdown’s own rule, and the one that keeps a half-typed string in a live editor from flickering between readings.

Day API ↩ Guides· daybrite.dev