diff --git a/__tests__/files/outlook-outlook/macos-macos/README.md b/__tests__/files/outlook-outlook/macos-macos/README.md index 13dce39dccf2ef4af3dc1fe500a5f59b2d647c4c..be46aa7af56d2d7ac01d6d3baed199a814a43f92 100644 --- a/__tests__/files/outlook-outlook/macos-macos/README.md +++ b/__tests__/files/outlook-outlook/macos-macos/README.md @@ -4,7 +4,7 @@ | 02 | Simple text | ok | ok | ok | | 03 | Embedded image | fail | ok | fail | | 04 | Embedded image with text | fail | ok | fail | -| 05 | Complex text on multiple lines with some text bold, italic, lists, no attachments | fail | ok | ok | +| 05 | Complex text on multiple lines with some text bold, italic, lists, no attachments | fail | ok | fail | | 06 | Multiple MIME attachments and text | ok | ok | ok | | 07 | Multiple Drive attachments and text | ok | ok | ok | | 08 | Complex email with formatted text, embedded images, MIME and GDrive attachments | fail | ok | fail | diff --git a/__tests__/htmltext-outlook-outlook.test.ts b/__tests__/htmltext-outlook-outlook.test.ts index cd8385a0c798c16298f5d2d33596481705f17aa4..2e96f56c571b7439840ad0793e83fe21c925e592 100644 --- a/__tests__/htmltext-outlook-outlook.test.ts +++ b/__tests__/htmltext-outlook-outlook.test.ts @@ -13,7 +13,13 @@ describe("[Pseudo PLAIN] Outlook-Outlook normalization", () => { EMAIL_VENDORS.OUTLOOK ); - describe("Chrome-Chrome", describeFunction("chrome-chrome")); - describe("MacOS-MacOS", describeFunction("macos-macos", ["09"])); - describe("Windows-Windows", describeFunction("windows-windows")); + describe("Chrome-Chrome", describeFunction("chrome-chrome", ["16"])); + describe( + "MacOS-MacOS", + describeFunction("macos-macos", ["03", "04", "05", "08", "09"]) + ); + describe( + "Windows-Windows", + describeFunction("windows-windows", ["11", "12", "16"]) + ); }); diff --git a/src/HTMLNormalizer/HTMLNormalizer.ts b/src/HTMLNormalizer/HTMLNormalizer.ts index ce2f1d3e84e413c530add95f471b66edb7295f74..601e7ee4ca938f9034d2fe923ed96efe312c075a 100644 --- a/src/HTMLNormalizer/HTMLNormalizer.ts +++ b/src/HTMLNormalizer/HTMLNormalizer.ts @@ -87,23 +87,26 @@ export const extractPseudoPlainPart = ( document: HTMLDocument /*vendor: string*/ ): string => { - const normalizedTextContent = PlainNormalizer.normalizePlain( + let normalizedTextContent = PlainNormalizer.normalizePlain( document.body.textContent ); - // const anchors = document.getElementsByTagName("a"); - // const images = document.getElementsByTagName("img"); - // let meaningfulAttributes = []; - // - // Array.from(anchors).forEach((a) => { - // meaningfulAttributes.push(a.getAttribute("href")); - // }); - // Array.from(images).forEach((img) => { - // meaningfulAttributes.push(img.getAttribute("src")); - // meaningfulAttributes.push(img.getAttribute("alt")); - // }); - // - // meaningfulAttributes = meaningfulAttributes.filter((attr) => !!attr).sort(); + const anchors = document.getElementsByTagName("a"); + const images = document.getElementsByTagName("img"); + let meaningfulAttributes = []; + + Array.from(anchors).forEach((a) => { + meaningfulAttributes.push(a.getAttribute("href")); + }); + Array.from(images).forEach((img) => { + meaningfulAttributes.push(img.getAttribute("src")); + meaningfulAttributes.push(img.getAttribute("alt")); + }); + + meaningfulAttributes = meaningfulAttributes.filter((attr) => !!attr).sort(); + + normalizedTextContent += meaningfulAttributes.join(","); + // console.log(meaningfulAttributes); return normalizedTextContent; };