mirror of
https://github.com/funamitech/mastodon
synced 2024-12-15 07:09:03 +09:00
10 lines
305 B
TypeScript
10 lines
305 B
TypeScript
// NB: This function can still return unsafe HTML
|
|
export const unescapeHTML = (html: string) => {
|
|
const wrapper = document.createElement('div');
|
|
wrapper.innerHTML = html
|
|
.replace(/<br\s*\/?>/g, '\n')
|
|
.replace(/<\/p><p>/g, '\n\n')
|
|
.replace(/<[^>]*>/g, '');
|
|
return wrapper.textContent;
|
|
};
|