diff options
-rwxr-xr-x | helpcontent2/to-wiki/wikiconv2.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py index acc2b97685..a9fd773845 100755 --- a/helpcontent2/to-wiki/wikiconv2.py +++ b/helpcontent2/to-wiki/wikiconv2.py @@ -281,6 +281,11 @@ class XhpFile(ElementBase): def __init__(self): ElementBase.__init__(self, None, None) + # we want to ignore the 1st level="1" heading, because in most of the + # cases, it is the only level="1" heading in the file, and it is the + # same as the page title + self.ignore_heading = True + def start_element(self, parser, name, attrs): if name == 'body': # ignored, we flatten the structure @@ -301,7 +306,18 @@ class XhpFile(ElementBase): elif name == 'meta': self.parse_child(Meta(attrs, self)) elif name == 'paragraph': - self.parse_child(Paragraph(attrs, self)) + ignore_this = False + try: + if attrs['role'] == 'heading' and int(attrs['level']) == 1 \ + and self.ignore_heading and parser.follow_embed: + self.ignore_heading = False + ignore_this = True + except: + pass + if ignore_this: + self.parse_child(Ignore(attrs, self, 'paragraph')) + else: + self.parse_child(Paragraph(attrs, self)) elif name == 'section': self.parse_child(Section(attrs, self)) elif name == 'sort': |