Co-authored-by: tobi <tobi.smethurst@protonmail.com> Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/88 Co-authored-by: Zoë Bijl <moiety@noreply.codeberg.org> Co-committed-by: Zoë Bijl <moiety@noreply.codeberg.org>
7 lines
282 B
JavaScript
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;
|
|
};
|