UNPKG

1.17 kBTypeScriptView Raw
1// Type definitions for escape-html 1.0
2// Project: https://github.com/component/escape-html
3// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/**
7 * Escape string for use in HTML
8 */
9
10/**
11 * Escape special characters in the given string of text, such that it can be interpolated in HTML content.
12 * This function will escape the following characters: `"`, `'`, `&`, `<`, and `>`.
13 *
14 * *Note* that the escaped value is only suitable for being interpolated into HTML as the text content of
15 * elements in which the tag does not have different escaping mechanisms (it cannot be placed inside
16 * `<style>` or `<script>`, for example, as those content bodies are not HTML, but CSS and JavaScript,
17 * respectively; these are known as "raw text elements" in the HTML standard).
18 *
19 * *Note* when using the escaped value within a tag, it is only suitable as the value of an attribute,
20 * where the value is quoted with either a double quote character (`"`) or a single quote character (`'`).
21 */
22declare function escapeHTML(text?: string | null): string;
23
24export = escapeHTML;