Name sections' list blocks
This commit was merged in pull request #132.
This commit is contained in:
@@ -23,17 +23,17 @@ def read_premises(root):
|
|||||||
|
|
||||||
|
|
||||||
def sections(text):
|
def sections(text):
|
||||||
headings, fenced = [], False
|
blocks, fenced = [], False
|
||||||
for line in text.splitlines():
|
for line in text.splitlines():
|
||||||
fenced ^= line.startswith("```")
|
fenced ^= line.startswith("```")
|
||||||
if not fenced and line.startswith("## "):
|
if not fenced and line.startswith("## "):
|
||||||
headings.append((line.strip()[3:], []))
|
blocks.append((line.strip()[3:], []))
|
||||||
elif not fenced and line.startswith("# "):
|
elif not fenced and line.startswith("# "):
|
||||||
headings.append((None, []))
|
blocks.append((None, []))
|
||||||
elif headings and line.strip():
|
elif blocks and line.strip():
|
||||||
headings[-1][1].append(line)
|
blocks[-1][1].append(line)
|
||||||
found = {}
|
found = {}
|
||||||
for name, body in headings:
|
for name, body in blocks:
|
||||||
if name is not None:
|
if name is not None:
|
||||||
found.setdefault(name, []).append("\n".join(body))
|
found.setdefault(name, []).append("\n".join(body))
|
||||||
return found
|
return found
|
||||||
|
|||||||
Reference in New Issue
Block a user