diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index c40f0e4..90ff004 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -464,9 +464,8 @@ class Headline: if isinstance(c, dom.ListItem) ] - if (len(list_children) == 0): - break - if ((len(list_children[-1].orig.indentation) + if ((len(list_children) > 0) + and (len(list_children[-1].orig.indentation) <= len(line.indentation))): # No more breaking out of lists, it's indentation # is less than ours diff --git a/tests/06-lists.org b/tests/06-lists.org index 1ee04e7..0c5448e 100644 --- a/tests/06-lists.org +++ b/tests/06-lists.org @@ -1,5 +1,5 @@ -#+TITLE: 06-Lists -#+DESCRIPTION: Simple org file to test lists +#+TITLE: 06-Links +#+DESCRIPTION: Simple org file to test links #+TODO: TODO(t) PAUSED(p) | DONE(d) diff --git a/tests/11-nested-lists.org b/tests/11-nested-lists.org deleted file mode 100644 index a4a8632..0000000 --- a/tests/11-nested-lists.org +++ /dev/null @@ -1,16 +0,0 @@ -#+TITLE: 11-Nested lists -#+DESCRIPTION: Simple org file to test nested lists -#+TODO: TODO(t) PAUSED(p) | DONE(d) - -* Nested lists - :PROPERTIES: - :ID: 11-nested-lists - :CREATED: [2020-01-01 Wed 01:01] - :END: - - 1 - - 1.1 - - 1.2 - - 2 - - 2.1 - - 2.2 - - 3 diff --git a/tests/test_org.py b/tests/test_org.py index 2f4200d..1255067 100644 --- a/tests/test_org.py +++ b/tests/test_org.py @@ -724,39 +724,6 @@ class TestSerde(unittest.TestCase): self.assertTrue(len(non_props) == 1, 'Expected , with only (1) element') - def test_nested_lists_html_file_11(self): - with open(os.path.join(DIR, "11-nested-lists.org")) as f: - doc = load(f) - - hl = doc.getTopHeadlines()[0] - - tree = hl.as_dom() - non_props = [ - item - for item in tree - if not isinstance(item, dom.PropertyDrawerNode) - ] - print_tree(non_props) - self.assertTrue((len(non_props) == 1) and (isinstance(non_props[0], dom.ListGroupNode)), - 'Expected only as top level') - - dom_list = non_props[0] - children = dom_list.children - self.assertTrue(len(children) == 5, 'Expected 5 items inside , 3 texts and 2 sublists') - - # Assert texts - self.assertEqual(children[0].content, ['1']) - self.assertEqual(children[2].content, ['2']) - self.assertEqual(children[4].content[0], '3') # Might be ['3', '\n'] but shouldn't be a breaking change - - # Assert lists - self.assertTrue(isinstance(children[1], dom.ListGroupNode), 'Expected sublist inside "1"') - self.assertEqual(children[1].children[0].content, ['1.1']) - self.assertEqual(children[1].children[1].content, ['1.2']) - self.assertTrue(isinstance(children[3], dom.ListGroupNode), 'Expected sublist inside "2"') - self.assertEqual(children[3].children[0].content, ['2.1']) - self.assertEqual(children[3].children[1].content, ['2.2']) - def print_tree(tree, indentation=0, headline=None): for element in tree: