From f9f3b89b2103d5d6868b022b170cb228045027c1 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 12 Nov 2010 09:07:02 +0100 Subject: wikihelp: Better way of converting comments. --- helpcontent2/to-wiki/wikiconv2.py | 57 ++++++++++----------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py index a2bb51f841..05edbc983e 100755 --- a/helpcontent2/to-wiki/wikiconv2.py +++ b/helpcontent2/to-wiki/wikiconv2.py @@ -7,14 +7,18 @@ root="source/" titles = [] -start_eles = [ - ["emph","'''"] +# list of elements that we can directly convert to wiki text +replace_start_list = [ + ["emph","'''"], + ["comment",""] ] +# text snippets that we need to convert replace_text_list = [ ["$[officename]","{{ProductName}}"], ["%PRODUCTNAME","{{ProductName}}"] @@ -209,30 +213,6 @@ class cbookmark: file.write(i.encode('ascii','replace')+"\n") file.close() -class ccomment: - def __init__(self, attrs, parent): - self.text = '' - self.parent = parent - - def start_element(self, name, attrs): - pass - - def end_element(self, name): - if name == 'comment': - self.parent.child_parsing = False - - def char_data(self, data): - self.text = self.text + data - - def get_all(self): - return "" - - def print_all(self): - print self.get_all() - - def get_curobj(self): - return self - class cimage: def __init__(self, attrs, parent): self.src = attrs['src'] @@ -516,17 +496,11 @@ class cparagraph: # This shouldn't occur print "Warning: Unhandled bookmark content!!!" - if name == 'comment': - child = ccomment(attrs, self) - self.child_parsing = True - self.objects.append(child) - - global start_eles - for n in start_eles: + global replace_start_list + for n in replace_start_list: if n[0] == name: - #self.wikitext=self.wikitext+n[1] self.objects.append(ctext(n[1])) - break + break def end_element(self, name): if name == 'paragraph': @@ -536,12 +510,11 @@ class cparagraph: if self.filter_section != "" and name == 'variable': self.parser_state = False - global end_eles - for n in end_eles: + global replace_end_list + for n in replace_end_list: if n[0] == name: - #self.wikitext=self.wikitext+n[1] self.objects.append(ctext(n[1])) - break + break def char_data(self, data): if not self.parser_state or not len(data.strip()): @@ -580,8 +553,6 @@ class cparagraph: for i in self.objects: try: raise i - except ccomment: - self.wikitext = self.wikitext + i.get_all() except ctext: self.wikitext = self.wikitext + i.wikitext except clink: -- cgit