Fichtelgard

Newline to Break

export function nl2br(str: string, is_xhtml: boolean = false) {
if (typeof str === "undefined" || str === null || !str.length) {
return "";
}
const breakTag =
is_xhtml || typeof is_xhtml === "undefined" ? "
" : "
";
return (str + "").replace(
/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,
"$1" + breakTag + "$2"
);
}