Commit afdf7ea4 authored by carignani's avatar carignani
Browse files

relax heading parser to address incorrect styles in document

parent 6069e204
......@@ -42,6 +42,14 @@ def get_example_file_name(line: str):
return matches.group(0)
return ""
def is_heading(txt :str):
'''
Returns true if text is a heading, i.e. the text starts with 'A.'
(Previously this predicate was used: ("Heading" in line.style.name) but
not all headings have the correct style
'''
return txt.startswith("A.")
def parse_all_examples(txt):
'''
Parses TOSCA examples. Txt is a list of Docx items (Paragraph, etc.).
......@@ -54,10 +62,9 @@ def parse_all_examples(txt):
i = 1
clause = ""
for line in txt:
if isinstance(line, Paragraph):
linetext = str(line.text)
if "Heading" in line.style.name:
if is_heading(linetext):
clause = linetext.split("\t")[0]
i = 1
elif isinstance(line, str):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment