Commits

JanKanis committed dc705e3

fix potential bug with cells containing "-1"; add Todo section to readme

Comments (0)

Files changed (2)

 - Correct wikitable syntax should be handled correctly, but if wiki2csv encounters bad wikitable syntax it can generate garbage output or crash. 
 
 
+Todo
+----
+
+The program is doing what I need it to do, so I have no significant improvements planned (though I do intend to fix bugs if they are found). However, the user interface is not yet very great. It would be very nice if someone was interested in either creating a GUI interface, or implementing this as a web service. (Using Google Appengine that shouldn't be too difficult.) Even better would be a plug-in for LibreOffice to allow it to directly edit wikitables, but that is probably a lot more work. 
+
+
 Contact & Bugs
 --------------
 
 		writer.writerow(row)
 
 
-rawtexttypes = re.compile('|'.join((re.escape(marker) for marker, type in wikitypes 
-		if type in actions['singlerow'] + actions['raw'])))
+rawtypes = re.compile('|'.join((re.escape(marker) for marker, type in wikitypes 
+		if type in actions['raw'])))
 singlerowtypes = re.compile('|'.join((re.escape(marker) for marker, type in wikitypes 
 		if type in actions['singlerow'])))
 
 	newrow = False
 	for line in reader:
 		for cell in line:
-			yield ('' if rawtexttypes.match(cell) else '|')+cell
+			if singlerowtypes.match(cell):
+				yield cell
+				break
+			elif rawtypes.match(cell):
+				yield cell
+			elif len(cell) and cell[0] in '-+}':
+				# Avoid a cornercase where a normal data cell has e.g. '-1' as content, 
+				# which would result in a new row marker
+				yield '| '+cell
+			else:
+				yield '|'+cell
 		if not singlerowtypes.match(cell):
 			yield '|-'