Tagged template based HTML-to-entities parser function.
Whitespace is handled like in real HTML: newlines and consecutive spaces
are collapsed into a single space. Use <br> for line breaks
and for multiple spaces.
Also has static methods:
html.escape - escape a string to be safely used in HTML
html.unparse - add HTML formatting to the text given the plain text and entities contained in it
Example
// whitespace is collapsed, <br> for newlines html` <b>Hello</b>, <i>world</i>! ` // => { text: 'Hello, world!' }
See
thtml for a variant that preserves whitespace as-is
Tagged template based HTML-to-entities parser function.
Whitespace is handled like in real HTML: newlines and consecutive spaces are collapsed into a single space. Use
<br>for line breaks and for multiple spaces.Also has static methods:
html.escape- escape a string to be safely used in HTMLhtml.unparse- add HTML formatting to the text given the plain text and entities contained in it