HTML escape modes.
Allows specifying a mode for HTML escaping that depends on the context where the escaped result is going to be used. The relevant contexts are:
All modes require escaping of & (ampersand) characters, and may enable escaping of more characters.
Custom escape modes can be created using the HtmlEscapeMode.HtmlEscapeMode constructor.
Example:
const htmlEscapeMode = HtmlEscapeMode( name: 'custom', escapeLtGt: true, escapeQuot: false, escapeApos: false, escapeSlash: false, ); const HtmlEscape htmlEscape = HtmlEscape(htmlEscapeMode); String unescaped = 'Text & subject'; String escaped = htmlEscape.convert(unescaped); print(escaped); // Text & subject unescaped = '10 > 1 and 1 < 10'; escaped = htmlEscape.convert(unescaped); print(escaped); // 10 > 1 and 1 < 10 unescaped = "Single-quoted: 'text'"; escaped = htmlEscape.convert(unescaped); print(escaped); // Single-quoted: 'text' unescaped = 'Double-quoted: "text"'; escaped = htmlEscape.convert(unescaped); print(escaped); // Double-quoted: "text" unescaped = 'Path: /system/'; escaped = htmlEscape.convert(unescaped); print(escaped); // Path: /system/
HtmlEscapeMode._('attribute', true, true, false, false) HtmlEscapeMode._('element', true, false, false, false) HtmlEscapeMode._('attribute', true, false, true, false) HtmlEscapeMode._('unknown', true, true, true, true)
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-convert/HtmlEscapeMode-class.html