adobe / helix-importer

Foundation tools for importing website content into that can be consumed in an Helix project.
Apache License 2.0
9 stars 18 forks source link

Anchor links generate corrupted Word documents #348

Open catalan-adobe opened 6 months ago

catalan-adobe commented 6 months ago

Description Anchor links <a href="#anchor-link">Anchor Link</a> in document to import will generate corrupted Word document

To Reproduce Steps to reproduce the behavior:

  1. Start the AEM Importer
  2. Force the "Transformation file URL" to a non existing URL to force usage of default import script
  3. Check "Save as docx"
  4. Import URL https://www.aami.com.au/
  5. Try to open the generated .docx => Word will display an error dialog: Word found unreadable content in index.docx. Do you want to recover the contents of this document? If you trust the source of this document, click Yes.

To confirm it's such elements which create the issue, retry the import with following import script:

export default {
  transformDOM: ({ document }) => {
    const main = document.body;

    // remove all anchor links
    main.querySelectorAll('a[href^="#"]').forEach((el) => el.remove());

    return main;
  },
};

=> The generated docx is OK.

Expected behavior If such anchor links are not supported, they should be modified/fixed by default

Version: 16.3.15