Skip to main content

Module escape

Module escape 

Source
Expand description

Manage XML character escapes.

This module mirrors quick-xml 0.41 escape: escape, partial_escape and minimal_escape replace XML special characters with entity references, while unescape / unescape_with reverse the process. Predefined XML entities are resolved by resolve_predefined_entity; with the escape-html feature enabled, the full set of HTML5 named references is recognized instead.

Enums§

EscapeError
Error for XML escape / unescape.
ParseCharRefError
Error while parsing a character reference (&#<dec-number>; or &#x<hex-number>;).

Functions§

escape
Escapes an &str, replacing all XML special characters (<, >, &, ', ") with their corresponding XML escape sequences.
minimal_escape
Escapes an &str, replacing only the characters (< and &) that the XML standard requires to be escaped in text content and attribute values.
normalize_attribute_value
Returns the attribute value normalized as per the XML specification, using a custom entity resolver.
partial_escape
Escapes an &str, replacing the XML special characters <, > and &.
resolve_html5_entityescape-html
Resolves all HTML5 entities. For the complete list see https://dev.w3.org/html5/html-author/charref.
resolve_predefined_entity
Resolves predefined XML entities, or all HTML5 entities when the escape-html feature is enabled.
resolve_xml_entity
Resolves the five predefined XML entities. Returns None for any other name.
unescape
Unescapes an &str, replacing all XML escapes (&...;) with their corresponding value.
unescape_with
Unescapes an &str, replacing all XML escapes (&...;) with their corresponding value, using resolve_entity for named entities.