Utility functions for HTML text.
- Source:
Methods
(inner) decodeHTML(str) → {string}
Decode the character references in HTML text, such as
&,
' and 😀.
Numeric references and the named ones that Markdown renderers output are decoded. Other named references are kept as they are.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
str |
string
|
HTML text. |
Returns:
- Type:
-
string
The text.
(inner) toPlainText(html) → {string}
Convert HTML to plain text on one line, for example to index or describe a page.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
html |
string
|
HTML. |
Returns:
- Type:
-
string
The text, with the tags removed, the character references decoded, and the
whitespace collapsed.