diff --git a/packages/app-cli/tests/enex_to_html/checklist-list.enex b/packages/app-cli/tests/enex_to_html/checkbox-list.enex similarity index 100% rename from packages/app-cli/tests/enex_to_html/checklist-list.enex rename to packages/app-cli/tests/enex_to_html/checkbox-list.enex diff --git a/packages/app-cli/tests/enex_to_html/checklist-list.html b/packages/app-cli/tests/enex_to_html/checkbox-list.html similarity index 100% rename from packages/app-cli/tests/enex_to_html/checklist-list.html rename to packages/app-cli/tests/enex_to_html/checkbox-list.html diff --git a/packages/app-cli/tests/enex_to_html/checklist.enex b/packages/app-cli/tests/enex_to_html/checklist.enex new file mode 100644 index 000000000..ab693bfee --- /dev/null +++ b/packages/app-cli/tests/enex_to_html/checklist.enex @@ -0,0 +1,11 @@ + +
+

In Evernote a checklist is not the same as a list with checkboxes.

+ + +
+
diff --git a/packages/app-cli/tests/enex_to_html/checklist.html b/packages/app-cli/tests/enex_to_html/checklist.html new file mode 100644 index 000000000..865659aaa --- /dev/null +++ b/packages/app-cli/tests/enex_to_html/checklist.html @@ -0,0 +1,19 @@ + +
+

In Evernote a checklist is not the same as a list with checkboxes.

+ +
+
\ No newline at end of file diff --git a/packages/app-cli/tests/enex_to_md/checklist.html b/packages/app-cli/tests/enex_to_md/checklist.html new file mode 100644 index 000000000..dfdc81cbb --- /dev/null +++ b/packages/app-cli/tests/enex_to_md/checklist.html @@ -0,0 +1,7 @@ + + +

More text

\ No newline at end of file diff --git a/packages/app-cli/tests/enex_to_md/checklist.md b/packages/app-cli/tests/enex_to_md/checklist.md new file mode 100644 index 000000000..81bfc6afa --- /dev/null +++ b/packages/app-cli/tests/enex_to_md/checklist.md @@ -0,0 +1,7 @@ +- [ ] One + +- [X] Two + +- [ ] Three + +More text \ No newline at end of file diff --git a/packages/lib/import-enex-html-gen.js b/packages/lib/import-enex-html-gen.js index 4e09b8e71..d83874a81 100644 --- a/packages/lib/import-enex-html-gen.js +++ b/packages/lib/import-enex-html-gen.js @@ -1,6 +1,7 @@ const stringToStream = require('string-to-stream'); // const cleanHtml = require('clean-html'); const resourceUtils = require('./resourceUtils.js'); +const { cssValue } = require('./import-enex-md-gen'); const htmlUtils = require('./htmlUtils').default; const Entities = require('html-entities').AllHtmlEntities; const htmlentities = new Entities().encode; @@ -80,6 +81,7 @@ function enexXmlToHtml_(stream, resources) { saxStream.on('opentag', function(node) { const tagName = node.name.toLowerCase(); const attributesStr = resourceUtils.attributesToStr(node.attributes); + const nodeAttributes = attributeToLowerCase(node); if (tagName === 'en-media') { const nodeAttributes = attributeToLowerCase(node); @@ -121,9 +123,11 @@ function enexXmlToHtml_(stream, resources) { section.lines = addResourceTag(section.lines, resource, nodeAttributes); } } else if (tagName === 'en-todo') { - const nodeAttributes = attributeToLowerCase(node); const checkedHtml = nodeAttributes.checked && nodeAttributes.checked.toLowerCase() === 'true' ? ' checked="checked" ' : ' '; section.lines.push(``); + } else if (tagName === 'li' && cssValue(this, nodeAttributes.style, '--en-checked')) { + const checkedHtml = cssValue(this, nodeAttributes.style, '--en-checked') === 'true' ? ' checked="checked" ' : ' '; + section.lines.push(`<${tagName}${attributesStr}> `); } else if (htmlUtils.isSelfClosingTag(tagName)) { section.lines.push(`<${tagName}${attributesStr}/>`); } else { diff --git a/packages/lib/import-enex-html-gen.test.js b/packages/lib/import-enex-html-gen.test.js index ecd130c51..24990750d 100644 --- a/packages/lib/import-enex-html-gen.test.js +++ b/packages/lib/import-enex-html-gen.test.js @@ -65,7 +65,11 @@ describe('EnexToHtml', function() { }); compareOutputToExpected({ - testName: 'checklist-list', + testName: 'checkbox-list', + }); + + compareOutputToExpected({ + testName: 'checklist', }); compareOutputToExpected({ diff --git a/packages/lib/import-enex-md-gen.ts b/packages/lib/import-enex-md-gen.ts index 6bb73c988..b93b754c4 100644 --- a/packages/lib/import-enex-md-gen.ts +++ b/packages/lib/import-enex-md-gen.ts @@ -35,8 +35,14 @@ interface ParserStateTag { isHighlight: boolean; } +enum ListTag { + Ul = 'ul', + Ol = 'ol', + CheckboxList = 'checkboxList', +} + interface ParserStateList { - tag: string; + tag: ListTag; counter: number; startedText: boolean; } @@ -738,7 +744,9 @@ function enexXmlToMdArray(stream: any, resources: ResourceEntity[]): Promise