Keep ### sub-headings inside their ## section when reading the premises
This commit is contained in:
+1
-1
@@ -87,7 +87,7 @@ def sections(text):
|
||||
if not fenced and line.startswith("## "):
|
||||
current = line.strip()[3:]
|
||||
found[current] = []
|
||||
elif not fenced and line.startswith("#"):
|
||||
elif not fenced and line.startswith("# "):
|
||||
current = None
|
||||
elif current and line.strip():
|
||||
found[current].append(line)
|
||||
|
||||
@@ -27,8 +27,8 @@ def human(content):
|
||||
|
||||
class Sections(unittest.TestCase):
|
||||
def test_keeps_only_headed_sections_with_a_body(self):
|
||||
text = "# Title\n\nintro\n\n## Goals\n\n1. one\n```sh\n# not a heading\n```\n2. two\n\n## Empty\n\n## Audience\nme\n# Appendix\nnot audience\n"
|
||||
self.assertEqual(loop.sections(text), {"Goals": "1. one\n```sh\n# not a heading\n```\n2. two", "Audience": "me"})
|
||||
text = "# Title\n\nintro\n\n## Goals\n\n1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n\n## Empty\n\n## Audience\nme\n# Appendix\nnot audience\n"
|
||||
self.assertEqual(loop.sections(text), {"Goals": "1. one\n```sh\n# not a heading\n```\n### Later\n2. two", "Audience": "me"})
|
||||
|
||||
|
||||
class Render(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user