Skip to main content

escape_text

Function escape_text 

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

Escape s for HTML TEXT content.

★ THE ONE DEFINITION. There were FOUR — escape_text and escape_attr in semantics::dom, htmlEscape in web.lg, and html_escape_literal in the lowering — and they disagreed about the quote, so a text hole holding one served " and painted ". Both look identical in a browser, which is exactly why it survived: the difference is in the bytes, and the bytes are what every cross-tier comparison in this codebase rests on. An escaper is also not a place to hold four opinions; the next disagreement would not be a cosmetic one.

It lives here beside VOID_ELEMENTS and URL_ATTRIBUTES for the same reason they do: this is the module every renderer already asks about HTML’s own rules.