~cytrogen/masto-fe

ref: e9a181c52c2a701a1f93782233111c234dab5342 masto-fe/app/javascript/mastodon/utils/html.js -rw-r--r-- 282 bytes
e9a181c5 — Claire Merge commit 'e95d25e1013b6328457b81bd98e8d6a841d45ec2' 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;
};