gab-social/app/javascript/gabsocial/utils/html.js

7 lines
282 B
JavaScript
Raw Normal View History

2019-07-02 08:10:25 +01:00
// 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;
};