mastodon/app/javascript/mastodon/utils/html.js
2018-07-05 19:19:38 +09:00

7 lines
282 B
JavaScript

// 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;
};