summaryrefslogtreecommitdiff
path: root/helpcontent2/to-wiki/wikiconv2.py
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2010-12-03 21:25:32 +0100
committerJan Holesovsky <kendy@suse.cz>2010-12-03 21:25:32 +0100
commit603ea085fdd57d62c0d627fa0b76061e027f171c (patch)
tree6b4d59cad2178ffedfacccf09f6214b91864b94c /helpcontent2/to-wiki/wikiconv2.py
parent75425dcc6f8e64e7226affa90c12a6123bb04ecf (diff)
wikihelp: Ignore the first level="1" heading.
It is usually (== everywhere but 2 or 3 files) the only level 1 heading in the file, and additionaly exactly the same as the page title. When we skip that, we get much nicer table of content, better structure, etc.
Diffstat (limited to 'helpcontent2/to-wiki/wikiconv2.py')
-rwxr-xr-xhelpcontent2/to-wiki/wikiconv2.py18
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':