3
def simple_parse(content):
4
"""Returns blocks, where each block is a 2-tuple (kind, text)."""
5
blocks = content.split('\n\n')
7
if block.startswith('###'):
8
# First line is ###...: Top heading
11
last_line = block.rsplit('\n', 1)[-1]
12
if last_line.startswith('###'):
13
# last line is ###...: 2nd-level heading
14
yield 'release', block
15
elif last_line.startswith('***'):
16
# last line is ***...: 3rd-level heading
17
yield 'section', block
18
elif block.startswith('* '):
21
elif block.strip() == '':
29
if __name__ == '__main__':
31
content = open(sys.argv[1], 'rb').read()
32
for result in simple_parse(content):