~cytrogen/masto-fe

ref: f8dc013b0d81d5d463c086e291ce99ab1d796a9d masto-fe/app/javascript/mastodon/utils/html.js -rw-r--r-- 282 bytes
f8dc013b — Cytrogen [feature] Add language selector to local settings 14 days 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;
};