From 8223f4ef4f94f5b852db277593cd945ff153a4e8 Mon Sep 17 00:00:00 2001
From: mic
/gi, '\n') // replace
with newline
+ .replace(/<\/p\s*>/gi, '\n') // replace
/gi, '') // remove
tag
+ .replace(/<[^>]*>/g, ' ') // remove any other HTML tags
+ .replace(/[ \t]+\n/g, '\n') // remove spaces before newline
+ .replace(/\n{2,}/g, '\n') // compress multiple newlines into one
+ .replace(/\s+/g, ' ') // normalize spaces inside lines
+ .trim(); // trim spaces at start and end
+}
+
export function convertNewlinesToBr(text) {
return text.replace(/\n/g, '
');
}