summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2010-11-12 09:07:02 +0100
committerJan Holesovsky <kendy@suse.cz>2010-11-12 09:07:02 +0100
commitf9f3b89b2103d5d6868b022b170cb228045027c1 (patch)
tree85e9d7a582a39125703c0c786eacf21bb1868ec6
parent1f2bcee68e3e28aea67ec3757704f0c5edb7f1c3 (diff)
wikihelp: Better way of converting comments.
-rwxr-xr-xhelpcontent2/to-wiki/wikiconv2.py57
1 files 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","<!-- "]
]
-end_eles = [
- ["emph","'''"]
+replace_end_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 "<!-- " + self.text + " -->"
-
- 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: