~cytrogen/masto-fe

ref: 01d6f7529faef97c0209ef11bbca2e856961bbab masto-fe/app/javascript/mastodon/utils/html.js -rw-r--r-- 282 bytes
01d6f752 — Claire Merge branch 'main' into glitch-soc/merge-upstream 3 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;
};