From d69bf97163d43a9d6936701d6becdcd0f05b856d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Thu, 29 Sep 2022 20:25:48 +0200 Subject: [PATCH] Require whitespace after list bullet. --- org_rw/org_rw.py | 4 ++-- tests/test_org.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index 8a9c08d..fce9f4f 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -88,7 +88,7 @@ PLANNING_RE = re.compile( r")+\s*" ) LIST_ITEM_RE = re.compile( - r"(?P\s*)((?P[*\-+])|((?P\d|[a-zA-Z])(?P[.)])))((?P)\[(?P[ Xx])\])?((?P\s*)(?P.*?)::)?(?P.*)" + r"(?P\s*)((?P[*\-+])|((?P\d|[a-zA-Z])(?P[.)]))) ((?P)\[(?P[ Xx])\])?((?P\s*)(?P.*?)::)?(?P.*)" ) # Org-Babel @@ -1528,7 +1528,7 @@ def dump_contents(raw): tag = f"{raw.tag_indentation}{token_list_to_raw(raw.tag)}::" if raw.tag else "" return ( raw.linenum, - f"{raw.indentation}{bullet}{checkbox}{tag}{content}", + f"{raw.indentation}{bullet} {checkbox}{tag}{content}", ) elif isinstance(raw, TableRow): diff --git a/tests/test_org.py b/tests/test_org.py index d5682d3..3509ffc 100644 --- a/tests/test_org.py +++ b/tests/test_org.py @@ -542,12 +542,12 @@ class TestSerde(unittest.TestCase): # ... lists = hl.getLists() self.assertEqual(len(lists), 3) - self.assertEqual(lists[0][0].content, [" This is a simple list."]) + self.assertEqual(lists[0][0].content, ["This is a simple list."]) self.assertEqual(lists[0][0].bullet, "-") self.assertEqual( lists[0][1].content, [ - " This list has multiple elements, with ", + "This list has multiple elements, with ", MarkerToken(closing=False, tok_type=MarkerType.UNDERLINED_MODE), "markup", MarkerToken(closing=True, tok_type=MarkerType.UNDERLINED_MODE), @@ -555,7 +555,7 @@ class TestSerde(unittest.TestCase): ], ) - self.assertEqual(lists[1][0].content, [" This is a simple list."]) + self.assertEqual(lists[1][0].content, ["This is a simple list."]) self.assertEqual(lists[1][0].bullet, "+") hl2 = doc.getTopHeadlines()[1] @@ -563,19 +563,19 @@ class TestSerde(unittest.TestCase): lists2 = hl2.getLists() self.assertEqual(len(lists2), 2) - self.assertEqual(lists2[0][0].content, [" First element"]) + self.assertEqual(lists2[0][0].content, ["First element"]) self.assertEqual(lists2[0][0].counter, "1") self.assertEqual(lists2[0][0].counter_sep, ".") - self.assertEqual(lists2[0][1].content, [" Second element"]) + self.assertEqual(lists2[0][1].content, ["Second element"]) self.assertEqual(lists2[0][1].counter, "2") self.assertEqual(lists2[0][1].counter_sep, ".") - self.assertEqual(lists2[1][0].content, [" First element"]) + self.assertEqual(lists2[1][0].content, ["First element"]) self.assertEqual(lists2[1][0].counter, "1") self.assertEqual(lists2[1][0].counter_sep, ")") - self.assertEqual(lists2[1][1].content, [" Second element"]) + self.assertEqual(lists2[1][1].content, ["Second element"]) self.assertEqual(lists2[1][1].counter, "2") self.assertEqual(lists2[1][1].counter_sep, ")")