UNPKG

echogarden

Version:

An easy-to-use speech toolset. Includes tools for synthesis, recognition, alignment, speech translation, language detection, source separation and more.

30 lines 817 B
export function escapeHtml(text) { return text.replaceAll(/[&<>"']/g, (char) => htmlEscapeLookup[char]); } const htmlEscapeLookup = { '&': '&amp;', '<': '&lt;', '>': '&gt;', "'": '&#39;', '"': '&quot;' }; // This HTML unescape method is not fully standard compliant // I implemented a fully compliant one in the package html-escape-compliant function unescapeHtml(text) { return text.replaceAll(/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160);/g, (str) => htmlUnescapeLookup[str]); } const htmlUnescapeLookup = { '&amp;': '&', '&#38;': '&', '&lt;': '<', '&#60;': '<', '&gt;': '>', '&#62;': '>', '&apos;': "'", '&#39;': "'", '&quot;': '"', '&#34;': '"', '&nbsp;': '\u00A0', '&#160;': '\u00A0' }; //# sourceMappingURL=HtmlEscape.js.map