UNPKG

html-document

Version:

Partial implementation of document, HTMLElement for node

11 lines (9 loc) 225 B
export default function escapeHTML(string) { if (!string) { return string; } return String(string) .replace(/&(?!\w+;)/g, '&amp;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;'); }