~cytrogen/masto-fe

ref: 44e98a2740b251ae4fe4c976afb3b30b23d3a6b7 masto-fe/app/javascript/mastodon/utils/html.js -rw-r--r-- 282 bytes
44e98a27 — Claire Merge branch 'main' 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;
};