(text)
| 4801 | nbsp: '\u00A0' |
| 4802 | }; |
| 4803 | function decodeEntities(text) { |
| 4804 | return text.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, function(_, code) { |
| 4805 | if (code[0] === '#') { |
| 4806 | const isHex = code[1] === 'x' || code[1] === 'X'; |
| 4807 | const num = parseInt(code.slice(isHex ? 2 : 1), isHex ? 16 : 10); |
| 4808 | if (!isNaN(num)) { |
| 4809 | try { return String.fromCodePoint(num); } catch(e) {} |
| 4810 | } |
| 4811 | return '&' + code + ';'; |
| 4812 | } |
| 4813 | const key = code.toLowerCase(); |
| 4814 | return (key in HTML_ENTITIES) ? HTML_ENTITIES[key] : '&' + code + ';'; |
| 4815 | }); |
| 4816 | } |
| 4817 | function parseHTMLToFragment(html, fragment, doc) { |
| 4818 | const stack = [fragment]; |
| 4819 | const tokenRe = /<!--[\s\S]*?-->|<!doctype[^>]*>|<\/?[a-zA-Z][^>]*>|[^<]+/gi; |
no outgoing calls
no test coverage detected