summaryrefslogtreecommitdiff
path: root/helpcontent2/to-wiki/wikiconv2.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpcontent2/to-wiki/wikiconv2.py')
-rwxr-xr-xhelpcontent2/to-wiki/wikiconv2.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py
index 1a1a173cdb..fbd3cb9198 100755
--- a/helpcontent2/to-wiki/wikiconv2.py
+++ b/helpcontent2/to-wiki/wikiconv2.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-import sys
+import sys, signal
import xml.parsers.expat
root="source/"
@@ -416,12 +416,7 @@ class cparagraph:
def char_data(self, data):
if not self.parser_state or not len(data.strip()):
return
- text=""
- if self.heading:
- text = heading(self.depth) + " " + data + " "+heading(self.depth)
- else:
- text = data
- self.objects.append(ctext(text))
+ self.objects.append(ctext(data))
#self.wikitext = self.wikitext + text
def print_all(self):
@@ -432,6 +427,10 @@ class cparagraph:
print text.encode('ascii','replace')
return
+ # mark this as the heading
+ if self.objects.len() > 0 and self.heading:
+ print heading(self.depth)
+
for i in self.objects:
try:
raise i
@@ -447,6 +446,10 @@ class cparagraph:
if len(self.wikitext):
print self.wikitext
+ # end of the heading mark
+ if self.objects.len() > 0 and self.heading:
+ print heading(self.depth)
+
def get_all(self):
for i in self.objects:
try:
@@ -494,6 +497,11 @@ def loadallfiles(filename):
title = line.split(";")
titles.append(title)
+def signal_handler(signal, frame):
+ sys.snderr.write( "You pressed Ctrl+C!" )
+ sys.exit(1)
+signal.signal(signal.SIGINT, signal_handler)
+
if len(sys.argv) < 2:
print "wikiconv2.py <inputfile.xph>"
sys.exit(1)