Skip to main content

decode_html_entities

Function decode_html_entities 

Source
pub fn decode_html_entities(s: &str) -> String
Expand description

Minimal HTML entity decoder for text-extraction call sites.

Handles the five XML/HTML named references (&, <, >, ", '), decimal (') and hex (') numeric character references, plus  . Unknown references pass through verbatim so the output for non-canonical input is the least surprising.

The set is deliberately narrow — search-index titles / headings / body text only ever contain these forms in practice, and a full HTML5-spec named-reference table would balloon binary size for no observable benefit.

§Examples

use ssg::util::html_rewriter::decode_html_entities;

assert_eq!(decode_html_entities("a & b"), "a & b");
assert_eq!(decode_html_entities("A"), "A");
assert_eq!(decode_html_entities("&unknown;"), "&unknown;");