~cytrogen/masto-fe

ref: 2d029dedd928681e8fa0c59b236ba89812ff5e92 masto-fe/app/javascript/mastodon/utils/html.js -rw-r--r-- 282 bytes
2d029ded — Claire Merge commit '0ad2413b35287958f59073a5b63aecc659a64d98' into glitch-soc/merge-upstream 2 years ago
                                                                                
1
2
3
4
5
6
// NB: This function can still return unsafe HTML
export const unescapeHTML = (html) => {
  const wrapper = document.createElement('div');
  wrapper.innerHTML = html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n').replace(/<[^>]*>/g, '');
  return wrapper.textContent;
};