unescapeHtml.js 539 B

123456789101112131415161718192021
  1. export function unescape(html) {
  2. return html
  3. .replace(html ? /&(?!#?\w+;)/g : /&/g, '')
  4. .replace(/&lt;/g, "<")
  5. .replace(/&gt;/g, ">")
  6. .replace(/&quot;/g, "\"")
  7. .replace(/&#39;/g, "\'")
  8. .replace(/nbsp;/g,"\u00a0")
  9. .replace(/&amp;/g,"")
  10. }
  11. export function unescapeHtml(html) {
  12. return html
  13. .replace(html ? /&(?!#?\w+;)/g : /&/g, '')
  14. .replace(/&lt;/g, "<")
  15. .replace(/&gt;/g, ">")
  16. .replace(/&quot;/g, "\"")
  17. .replace(/&#39;/g, "\'")
  18. .replace(/nbsp;/g,"\u00a0")
  19. .replace(/&amp;/g,"")
  20. }