chuckya/app/javascript/flavours/glitch/util/html.js
2018-06-16 15:09:28 +02:00

5 lines
232 B
JavaScript

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