diff options
author | Jan Holesovsky <kendy@suse.cz> | 2010-11-19 16:37:06 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2010-11-19 16:37:42 +0100 |
commit | 9b2cc70db6595b5f6067aed4fac5703d45bc5f80 (patch) | |
tree | e0467a9c31b27f8c86db9dac0c136b8e704be753 /helpcontent2/to-wiki | |
parent | df9096834a89fde2bfee0e84e35ecc0a42c8d0ac (diff) |
wikihelp: Handle <switch>/<case>/<default>.
Diffstat (limited to 'helpcontent2/to-wiki')
-rwxr-xr-x | helpcontent2/to-wiki/wikiconv2.py | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py index 1327e55e42..1a9e58a2bf 100755 --- a/helpcontent2/to-wiki/wikiconv2.py +++ b/helpcontent2/to-wiki/wikiconv2.py @@ -289,6 +289,8 @@ class XhpFile(ElementBase): self.parse_child(para) elif name == 'section': self.parse_child(Section(attrs, self, self.depth)) + elif name == 'switch': + self.parse_child(Switch(attrs, self)) elif name == 'table': self.parse_child(Table(attrs, self)) else: @@ -449,10 +451,19 @@ class TableCell(ElementBase): ElementBase.__init__(self, 'tablecell', parent) def start_element(self, parser, name, attrs): - if name == 'comment': + if name == 'bookmark': + self.parse_child(Bookmark(attrs, self)) + elif name == 'comment': self.parse_child(Comment(attrs, self)) + elif name == 'embed' or name == 'embedvar': + (fname, id) = href_to_fname_id(attrs['href']) + if parser.follow_embed: + self.embed_href(parser.current_app, fname, id) elif name == 'paragraph': self.parse_child(Paragraph(attrs, self, 0)) + elif name == 'section': + # FIXME depth, should we use something better than 0? + self.parse_child(Section(attrs, self, 0)) else: self.unhandled_element(parser, name) @@ -494,7 +505,13 @@ class ListItem(ElementBase): ElementBase.__init__(self, 'listitem', parent) def start_element(self, parser, name, attrs): - if name == 'paragraph': + if name == 'bookmark': + self.parse_child(Bookmark(attrs, self)) + elif name == 'embed' or name == 'embedvar': + (fname, id) = href_to_fname_id(attrs['href']) + if parser.follow_embed: + self.embed_href(parser.current_app, fname, id) + elif name == 'paragraph': self.parse_child(Paragraph(attrs, self, 0)) else: self.unhandled_element(parser, name) @@ -574,6 +591,8 @@ class Section(ElementBase): elif name == 'section': # sections can be nested self.parse_child(Section(attrs, self, self.depth)) + elif name == 'switch': + self.parse_child(Switch(attrs, self)) elif name == 'table': self.parse_child(Table(attrs, self)) else: @@ -667,6 +686,8 @@ class SwitchInline(ElementBase): text = '%s|%s=%s'% (text, i[1], system[i[0]]) return text + '}}' elif self.switch == 'appl': + # we want directly use the right text, when inlining something + # 'shared' into an 'app' if self.embedding_app == '': text = '' for i in self.objects: @@ -687,6 +708,52 @@ class SwitchInline(ElementBase): return '' +class Case(ElementBase): + def __init__(self, attrs, parent, is_default): + ElementBase.__init__(self, 'case', parent) + + if is_default: + self.name = 'default' + self.case = 'default' + else: + self.case = attrs['select'] + + def start_element(self, parser, name, attrs): + if name == 'bookmark': + self.parse_child(Bookmark(attrs, self)) + elif name == 'comment': + self.parse_child(Comment(attrs, self)) + elif name == 'embed' or name == 'embedvar': + if parser.follow_embed: + (fname, id) = href_to_fname_id(attrs['href']) + self.embed_href(parser.current_app, fname, id) + elif name == 'list': + self.parse_child(List(attrs, self)) + elif name == 'paragraph': + # FIXME depth, should we use something better than 0? + self.parse_child(Paragraph(attrs, self, 0)) + elif name == 'section': + # FIXME depth, should we use something better than 0? + self.parse_child(Section(attrs, self, 0)) + elif name == 'table': + self.parse_child(Table(attrs, self)) + else: + self.unhandled_element(parser, name) + +class Switch(SwitchInline): + def __init__(self, attrs, parent): + SwitchInline.__init__(self, attrs, parent) + self.name = 'switch' + + def start_element(self, parser, name, attrs): + self.embedding_app = parser.embedding_app + if name == 'case': + self.parse_child(Case(attrs, self, False)) + elif name == 'default': + self.parse_child(Case(attrs, self, True)) + else: + self.unhandled_element(parser, name) + class Item(ElementBase): replace_type = \ {'start':{'input': '<code>', |