Build premises.sections without filling found through an alias

This commit is contained in:
2026-09-29 11:36:43 +02:00
parent e7b0479092
commit 69b093d1a7
2 changed files with 10 additions and 8 deletions
+10 -7
View File
@@ -23,14 +23,17 @@ def read_premises(root):
def sections(text):
found, current, fenced = {}, None, False
headings, fenced = [], False
for line in text.splitlines():
fenced ^= line.startswith("```")
if not fenced and line.startswith("## "):
current = []
found.setdefault(line.strip()[3:], []).append(current)
headings.append((line.strip()[3:], []))
elif not fenced and line.startswith("# "):
current = None
elif current is not None and line.strip():
current.append(line)
return {name: ["\n".join(body) for body in bodies] for name, bodies in found.items()}
headings.append((None, []))
elif headings and line.strip():
headings[-1][1].append(line)
found = {}
for name, body in headings:
if name is not None:
found.setdefault(name, []).append("\n".join(body))
return found