2020-11-27 19:27:44 +01:00
|
|
|
export function nl2br(text: string): string {
|
2020-02-18 08:57:00 +01:00
|
|
|
return text.replace(/(?:\r\n|\r|\n)/g, "<br>");
|
2019-04-26 15:22:16 +02:00
|
|
|
}
|
2022-08-12 16:46:44 +02:00
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
export function htmlToText(html: string) {
|
|
|
|
const template = document.createElement("template");
|
|
|
|
const trimmedHTML = html.trim();
|
|
|
|
template.innerHTML = trimmedHTML;
|
|
|
|
const text = template.content.textContent;
|
|
|
|
template.remove();
|
|
|
|
return text;
|
2022-08-12 16:46:44 +02:00
|
|
|
}
|