~cytrogen/masto-fe

ref: b83e487502d2c6cd5027c27dec6f056de8a90d1c masto-fe/app/javascript/mastodon/utils/html.js -rw-r--r-- 282 bytes
b83e4875 — Claire Fix moderator rights inconsistencies (#26729) 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;
};