[][src]Function html2pango::markup

pub fn markup(s: &str) -> String

Sanitize the input using ammonia's defaults, Convert the input &str to pango format and parse URLS to show as pango markup links(removes rel attributes).

If you want to parse a pre-sanitized input, you can use markup_from_raw.

Currently it support conversion of the following html tags:

  • <p> and </p> => ""
  • <i>, <em> and </i>,</em> => <i> and ```
  • <b>, <strong> and </b>, </strong> => <b> and </b>
  • <br> => \n
  • rest < => &lt
  • rest > => &gt
  • &nbsp; =>   (non breaking space)

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>");