diff --git a/packages/app-cli/tests/enex_to_md/table_with_invalid_content.html b/packages/app-cli/tests/enex_to_md/table_with_invalid_content.html index f74f7fb2c..ea972c3c8 100644 --- a/packages/app-cli/tests/enex_to_md/table_with_invalid_content.html +++ b/packages/app-cli/tests/enex_to_md/table_with_invalid_content.html @@ -1,4 +1,5 @@ +
diff --git a/packages/lib/import-enex-md-gen.test.ts b/packages/lib/import-enex-md-gen.test.ts index 705ea085e..6923c5ec6 100644 --- a/packages/lib/import-enex-md-gen.test.ts +++ b/packages/lib/import-enex-md-gen.test.ts @@ -142,22 +142,28 @@ describe('import-enex-md-gen', () => { expect(all[0].mime).toBe('application/zip'); }); - it('should keep importing notes when one of them is corrupted', async () => { - const filePath = `${enexSampleBaseDir}/ImportTestCorrupt.enex`; - const errors: any[] = []; - const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(jest.fn()); - await importEnex('', filePath, { - onError: (error: any) => errors.push(error), - }); - consoleSpy.mockRestore(); - const notes = await Note.all(); - expect(notes.length).toBe(2); + // Disabled for now because the ENEX parser has become so error-tolerant + // that it's no longer possible to generate a note that would generate a + // failure. - // Check that an error was recorded and that it includes the title - // of the note, so that it can be found back by the user - expect(errors.length).toBe(1); - expect(errors[0].message.includes('Note 2')).toBe(true); - }); + // it('should keep importing notes when one of them is corrupted', async () => { + // const filePath = `${enexSampleBaseDir}/ImportTestCorrupt.enex`; + // const errors: any[] = []; + // const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(jest.fn()); + // await importEnex('', filePath, { + // onError: (error: any) => errors.push(error), + // }); + // consoleSpy.mockRestore(); + // const notes:NoteEntity[] = await Note.all(); + // expect(notes.length).toBe(2); + // expect(notes.find(n => n.title === 'Note 1')).toBeTruthy(); + // expect(notes.find(n => n.title === 'Note 3')).toBeTruthy(); + + // // Check that an error was recorded and that it includes the title + // // of the note, so that it can be found back by the user + // expect(errors.length).toBe(1); + // expect(errors[0].message.includes('Note 2')).toBe(true); + // }); it('should throw an error and stop if the outer XML is invalid', async () => { await expectThrow(async () => importEnexFile('invalid_html.enex')); diff --git a/packages/lib/import-enex-md-gen.ts b/packages/lib/import-enex-md-gen.ts index 20779b426..8394cee0d 100644 --- a/packages/lib/import-enex-md-gen.ts +++ b/packages/lib/import-enex-md-gen.ts @@ -1241,6 +1241,14 @@ function drawTable(table: Section) { continue; } + if (typeof tr === 'string') { + // A
one two
tag should only have tags as direct children. + // However certain Evernote notes can contain other random tags + // such as empty DIVs. In that case we just skip the content. + // See test "table_with_invalid_content.html". + continue; + } + const isHeader = tr.isHeader; const line = []; const headerLine = []; @@ -1249,10 +1257,7 @@ function drawTable(table: Section) { const td = tr.lines[tdIndex]; if (typeof td === 'string') { - // A tag should only have tags. continue; }
tags as direct children. - // However certain Evernote notes can contain other random tags - // such as empty DIVs. In that case we just skip the content. - // See test "table_with_invalid_content.html". + // Same comment as above the