Skip to main content

decode_html_entities

Function decode_html_entities 

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

Decode HTML5 character references (&gt;, &amp;, &#x3C;, &#123;, …) inside a string. Unrecognised &foo runs are left as-is.

JSX text and JSX literal attribute values both go through HTML entity decoding before reaching the runtime: <p>&gt;</p> and <p title="&gt;"/> both materialise as a > character. This helper is shared so the two call sites agree on the entity table.