Require whitespace after list bullet.

This commit is contained in:
Sergio Martínez Portela 2022-09-29 20:25:48 +02:00
parent 28d8b69146
commit d69bf97163
2 changed files with 9 additions and 9 deletions

View File

@ -88,7 +88,7 @@ PLANNING_RE = re.compile(
r")+\s*"
)
LIST_ITEM_RE = re.compile(
r"(?P<indentation>\s*)((?P<bullet>[*\-+])|((?P<counter>\d|[a-zA-Z])(?P<counter_sep>[.)])))((?P<checkbox_indentation>)\[(?P<checkbox_value>[ Xx])\])?((?P<tag_indentation>\s*)(?P<tag>.*?)::)?(?P<content>.*)"
r"(?P<indentation>\s*)((?P<bullet>[*\-+])|((?P<counter>\d|[a-zA-Z])(?P<counter_sep>[.)]))) ((?P<checkbox_indentation>)\[(?P<checkbox_value>[ Xx])\])?((?P<tag_indentation>\s*)(?P<tag>.*?)::)?(?P<content>.*)"
)
# 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):

View File

@ -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, ")")