diff --git a/src/example.py b/src/example.py index ab8fde350217943c1c8f4427a07a457a653d3f04..971ccc999388f7fadb331af0d307798cd0b67540 100644 --- a/src/example.py +++ b/src/example.py @@ -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):