diff options
author | Jan Holesovsky <kendy@suse.cz> | 2010-12-09 12:48:57 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2010-12-09 12:48:57 +0100 |
commit | de09480929be4ad1bb6b731183732cfd3338407f (patch) | |
tree | 03cd56203f3886da04adcc9accdb6bba5f107854 /helpcontent2/to-wiki | |
parent | bc2c698b7ca4f515ab142c4e1da1fcd43fa2d573 (diff) |
wikihelp: Fix handling of listitems, and the paragraphs in them. fdo#32174
Diffstat (limited to 'helpcontent2/to-wiki')
-rwxr-xr-x | helpcontent2/to-wiki/wikiconv2.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py index d29b3e69f5..d440328f19 100755 --- a/helpcontent2/to-wiki/wikiconv2.py +++ b/helpcontent2/to-wiki/wikiconv2.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import sys, signal +import sys import thread, threading, time import xml.parsers.expat import codecs @@ -69,7 +69,7 @@ replace_paragraph_role = \ 'heading6': ' ======\n\n', 'head1': ' =\n\n', # used only in one file, probably in error? 'head2': ' ==\n\n', # used only in one file, probably in error? - 'listitem': '\n', + 'listitem': '', 'note': '}}\n\n', 'null': '', # special paragraph for Variable, CaseInline, etc. 'paragraph': '\n\n', @@ -577,25 +577,28 @@ class ListItem(ElementBase): if parser.follow_embed: self.embed_href(parser, fname, id) elif name == 'paragraph': - parser.parse_paragraph(attrs, self) + self.parse_child(ListItemParagraph(attrs, self)) else: self.unhandled_element(parser, name) def get_all(self): - text = "" - prefix = '*' - postfix = '' + text = '*' + postfix = '\n' if self.parent.startwith > 0: - prefix = '<li>' + text = '<li>' postfix = '</li>' elif self.parent.type == 'ordered': - prefix = '#' + text = '#' # add the text itself + linebreak = False for i in self.objects: - text = text + prefix + ElementBase.get_all(self) + if linebreak: + text = text + '<br/>' + text = text + i.get_all() + linebreak = True - return text + return text + postfix class List(ElementBase): def __init__(self, attrs, parent): @@ -1070,6 +1073,12 @@ class CaseInline(Paragraph): self.name = 'caseinline' self.case = attrs['select'] +class ListItemParagraph(Paragraph): + def __init__(self, attrs, parent): + Paragraph.__init__(self, attrs, parent) + + self.role = 'null' + class XhpParser: def __init__(self, filename, follow_embed, embedding_app, wiki_page_name): self.head_obj = XhpFile() @@ -1146,11 +1155,6 @@ def loadallfiles(filename): titles.append(title) file.close() -def signal_handler(signal, frame): - sys.stderr.write( 'Exiting...\n' ) - sys.exit(1) -signal.signal(signal.SIGINT, signal_handler) - class WikiConverter(Thread): def __init__(self, inputfile, wiki_page_name, outputfile): Thread.__init__(self) |