Skip to main content

parse_markup

Function parse_markup 

Source
pub fn parse_markup(body: &str) -> Vec<Span>
Expand description

Turns a notification body in the Desktop Notifications spec’s markup into spans: <b>, <i>, <u>, <a href="..."> and <img src="..." alt="..."/>, nested in any order, with the five XML entities and numeric character references. It never reads general HTML.

Unknown tags are dropped and their text kept. A < that doesn’t start a tag, a bad entity and a close tag nothing opened stay or go as plain text; a tag left open lasts to the end. An img shows its alt, and its src is never read. A link is kept only for an href starting with http:, https: or mailto:; any other a is plain text, since a notification can come from any program. Links are underlined. A body over MARKUP_CAP bytes is cut before it is read, logged once.