Function html2pango::markup

source ·
pub fn markup(s: &str) -> String
Expand description

Sanitizes and converts simple HTML markup to Pango Markup.

This will sanitize the input string using the ammonia crate’s defaults and then use markup_from_raw to convert the sanitized string to Pango Markup.

Examples

let m = markup("this is parsed");
assert_eq!(m, "this is parsed");

let m = markup("<b>this <i>is &ssd<f;</i></b>");
assert_eq!(m, "<b>this <i>is &amp;ssd</i></b>");

let m = markup("this is <span>parsed</span>");
assert_eq!(m, "this is &lt;span&gt;parsed&lt;/span&gt;");

let m = markup("with links: http://gnome.org");
assert_eq!(m, "with links: <a href=\"http://gnome.org\">http://gnome.org</a>");