From 4eca609ecf1e0fb3f97d476f3403f2b4d0e04acd Mon Sep 17 00:00:00 2001 From: Gal Falkon <> Date: Sat, 27 Nov 2021 21:33:44 +0200 Subject: [PATCH] Fix #676: Trying to keep current formatting intact --- src/common/mdh-html-to-text.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/mdh-html-to-text.js b/src/common/mdh-html-to-text.js index 746d957cd..32d811360 100644 --- a/src/common/mdh-html-to-text.js +++ b/src/common/mdh-html-to-text.js @@ -105,6 +105,14 @@ MdhHtmlToText.prototype._preprocess = function() { // to remain intact. this.excludeTagBlocks('blockquote', true); + // Trying to keep current formatting intact (see issue #676) + for (const tagName of ['b','i','u','strike']) { + this.preprocessInfo.html = this.preprocessInfo.html.replace( + new RegExp(`<${tagName}>(.*?)<\/${tagName}>`, 'ig'), + `<${tagName}>$1<\/${tagName}>` + ); + } + // Try to leave intact the line that Gmail adds that says: // On such-a-date, such-a-person wrote: this.preprocessInfo.html = this.preprocessInfo.html.replace(