Skip to main content

decode_html_text

Function decode_html_text 

Source
pub fn decode_html_text(s: &str) -> Cow<'_, str>
Expand description

Expand character references in HTML text.

Handles &name;, &#123; and &#x7B;. Anything that is not a reference is left exactly as written, which is what a browser does and what a converter needs: a bare & in AT&T must survive.

HTML permits a named reference without its semicolon (&amp and &ampX both yield &), so the longest matching name is taken when the semicolon is missing. Borrows when there is nothing to expand.