diff --git a/js/mzta-utils.js b/js/mzta-utils.js index ddfc2fbf..732e29b0 100644 --- a/js/mzta-utils.js +++ b/js/mzta-utils.js @@ -201,15 +201,16 @@ export function stripHtmlKeepLines(htmlString) { export function htmlBodyToPlainText(html) { return html - .replace(/
/gi, '') // remove and its content - .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 + .replace(/
/gi, '') + .replace(//gi, '') + .replace(/<\/(div|section|article|li|ul|ol|table|tr|td|th)>/gi, '\n') // newline for block tags + .replace(/<[^>]*>/g, '') // remove all other tags with no extra spaces + .replace(/[ \t]+\n/g, '\n') + .replace(/\n{2,}/g, '\n') + .replace(/[ \t]+/g, ' ') + .trim(); } export function convertNewlinesToBr(text) {