about summary refs log tree commit diff
path: root/app/javascript/mastodon/utils/html.js
blob: 247e98c88a7f31f2259570ee257385b4fd0f33a9 (plain) (blame)
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;
};