From 14f24c646a2832b0673a33b41f688684710f2f74 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Wed, 29 Sep 2021 09:11:04 -0700 Subject: [PATCH] enex: Convert OneNote (via Evernote) todo images to Unicode checkboxes (#2189) When a OneNote todo bullet is imported by Evernote it is converted to an image showing the checkbox the way it looked in OneNote. This change takes advantage of the consistency of that image hashing to convert those images into unicode checkboxes (matching the existing ENEX behavior) . It also removes the image attachments. --- src/services/import/enex.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/services/import/enex.js b/src/services/import/enex.js index a9331d9f1..710283b09 100644 --- a/src/services/import/enex.js +++ b/src/services/import/enex.js @@ -73,6 +73,11 @@ function importEnex(taskContext, file, parentNote) { content = content.replace(//g, "\u2611 "); content = content.replace(//g, "\u2610 "); + // Replace OneNote converted checkboxes with unicode ballot box based + // on known hash of checkboxes for regular, p1, and p2 checkboxes + content = content.replace(//g, "\u2610 "); + content = content.replace(//g, "\u2611 "); + content = htmlSanitizer.sanitize(content); return content; @@ -243,6 +248,16 @@ function importEnex(taskContext, file, parentNote) { const hash = utils.md5(resource.content); + // skip all checked/unchecked checkboxes from OneNote + if (['74de5d3d1286f01bac98d32a09f601d9', + '4a19d3041585e11643e808d68dd3e72f', + '8e17580123099ac6515c3634b1f6f9a1', + '5069b775461e471a47ce04ace6e1c6ae', + '7912ee9cec35fc3dba49edb63a9ed158', + '3a05f4f006a6eaf2627dae5ed8b8013b'].includes(hash)) { + continue; + } + const mediaRegex = new RegExp(`]*>`, 'g'); resource.mime = resource.mime || "application/octet-stream";