diff --git a/packages/markdown-slate/src/ToSlateVisitor.js b/packages/markdown-slate/src/ToSlateVisitor.js index 77065042..b810d301 100644 --- a/packages/markdown-slate/src/ToSlateVisitor.js +++ b/packages/markdown-slate/src/ToSlateVisitor.js @@ -110,7 +110,7 @@ class ToSlateVisitor { processChildNodes(thing) { const result = []; if(!thing.nodes) { - throw new Error(`Node ${thing.getType()} doesn't have any children!`); + thing.nodes = []; // Treat no nodes as empty array of nods } thing.nodes.forEach(node => { diff --git a/packages/markdown-slate/src/__snapshots__/SlateTransformer.test.js.snap b/packages/markdown-slate/src/__snapshots__/SlateTransformer.test.js.snap index 4afd7cb5..53c871f8 100644 --- a/packages/markdown-slate/src/__snapshots__/SlateTransformer.test.js.snap +++ b/packages/markdown-slate/src/__snapshots__/SlateTransformer.test.js.snap @@ -2098,6 +2098,10 @@ Object { }, ], }, + Object { + "$class": "org.accordproject.commonmark.Item", + "nodes": Array [], + }, ], "start": undefined, "tight": "true", @@ -2131,6 +2135,7 @@ exports[`slate converts nested-list.json to and from CiceroMark 2`] = ` - sublist - sublist with some text in the same paragraph + - Epilog " @@ -2250,6 +2255,12 @@ Object { "object": "block", "type": "list_item", }, + Object { + "data": Object {}, + "nodes": Array [], + "object": "block", + "type": "list_item", + }, ], "object": "block", "type": "ul_list", @@ -2363,6 +2374,10 @@ Object { }, ], }, + Object { + "$class": "org.accordproject.commonmark.Item", + "nodes": Array [], + }, ], "start": undefined, "tight": "true", diff --git a/packages/markdown-slate/test/data/nested-list.json b/packages/markdown-slate/test/data/nested-list.json index cc009a8e..3fc67237 100644 --- a/packages/markdown-slate/test/data/nested-list.json +++ b/packages/markdown-slate/test/data/nested-list.json @@ -116,6 +116,12 @@ ] } ] + }, + { + "object": "block", + "type": "list_item", + "data": {}, + "nodes": [] } ] } diff --git a/packages/markdown-slate/test/data/nested-list.md b/packages/markdown-slate/test/data/nested-list.md index 06d52372..d9f9e1a3 100644 --- a/packages/markdown-slate/test/data/nested-list.md +++ b/packages/markdown-slate/test/data/nested-list.md @@ -4,5 +4,6 @@ Prolog - sublist - sublist with some text in the same paragraph + - Epilog