From afdf7ea43dfd129ce7917e5bf67cb2884ec8e1ec Mon Sep 17 00:00:00 2001
From: Michele Carignani <michele.carignani@etsi.org>
Date: Mon, 30 Nov 2020 16:49:05 +0100
Subject: [PATCH] relax heading parser to address incorrect styles in document

---
 src/example.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/example.py b/src/example.py
index ab8fde3..971ccc9 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):
-- 
GitLab