Build premises.sections without filling found through an alias
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user