1
0
puyopuyotetr.is/app/javascript/flavours/glitch/utils/html.js
2023-11-15 12:53:21 +01: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;
};