yarle: Content is lost when converting nested lists

If the exported .enex contains a nested list structure, the contents of the list elements that have sub-lists are no longer present after the conversion.

Steps to reproduce

npx -p yarle-evernote-to-md@latest yarle --configFile ./config.json

Configuration

config.json

{
    "enexSources": [
       "/path/to/file/test.enex"
       ],
    "templateFile": "/path/to/file/template.tmpl",
    "outputDir": "/path/to/file/converted",
    "resourcesDir": "_resources",
    "isZettelkastenNeeded": false,
    "plainTextNotesOnly": false,    
    "useHashTags": false,
    "outputFormat": "ObsidianMD",
    "haveEnexLevelResources": false,
    "monospaceIsCodeBlock": false,
    "dateFormat": "DD.MM.YYYY hh:mm",
    "keepMDCharactersOfENNotes": false,
    "keepImageSize": "ObsidianMD",
    "urlEncodeFileNamesAndLinks": false,
    "skipEnexFileNameFromOutputPath": false,
    "keepOriginalAmountOfNewlines": false,
    "generateNakedUrls": true,
    "addExtensionToInternalLinks": true
}

Input

test.enex

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd">
<en-export export-date="20210926T114156Z" application="Evernote Legacy" version="Evernote Mac 7.14.1 (458325)">
<note><title>Test note</title><content><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note>
<ul>
    <li>
        List item 1
        <ul>
            <li>
                List item 1.1
                <ul>
                    <li>
                        List item 1.1.1
                    </li>
                </ul>
            </li>
            <li>
                List item 1.2
                <ul>
                    <li>
                        List item 1.2.1
                        <ul>
                            <li>
                                List item 1.2.1.1
                            </li>
                        </ul>
                    </li>
                </ul>
            </li>
            <li>
                List item 1.3
            </li>
        </ul>
    </li>
    <li>
        List item 2
        <ul>
            <li>
                List item 2.1
            </li>
        </ul>
    </li>
    <li>List item 3</li>
</ul>
</en-note>
]]></content><created>20160309T134711Z</created><updated>20160420T141949Z</updated><note-attributes></note-attributes></note>
</en-export>

Output

Test note.md

---
created-at: 09.03.2016 02:47
updated-at: 20.04.2016 04:19

---
*   List item 1.1.1

*   List item 1.2.1.1

*   List item 1.3

*   List item 2.1

*   List item 3

Missing list-items

All list-items that have nested lists within get lost.

List item 1 List item 1.1 List item 1.2 List item 1.2.1 List item 2


Environmental characteristics

  • Yarle 4.5.3
  • Node 16.8.0
  • NPM 7.21.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

it looks @joaosa fixed this issue, released in 4.8.3.

@cyress , I released my fix in 4.9.13, please take a look at it. Thank you!

Adding something like this to top of fixSublists seems to correct the issue.

const unwrapElement = (node: Element) => { node.replaceWith(...Array.from(node.children)); };

for (const ulNode of ulElements) {
  const parentNodeDiv = ulNode.parentElement;
  if (parentNodeDiv && parentNodeDiv.tagName === 'DIV') {
    unwrapElement(parentNodeDiv);
  }
}

Let me know if you’d like me to submit a PR.