',r"",the_text)
+ the_text = re.sub(r'^\s*| ]*>',r"",the_text)
+ the_text = re.sub(r' | \s*$',r"",the_text)
+
+ the_text = re.sub(r'\s*',r"&",the_text)
+# the_cells = re.split(r' | \s*', the_text)
+
+# if "\\amp\\amp\\amp" in the_text:
+# the_text += "}"
+# try:
+# text_before, text_after = the_text.split("\\amp\\amp\\amp")
+# text_before = re.sub("*m>","",text_before)
+# text_before = re.sub(r"\\\(","",text_before)
+# text_before = re.sub(r"\\\)","",text_before)
+# the_text = text_before + text_after
+# except ValueError:
+# print "too many amp"
+# print the_text
+
+ the_cells = the_text.split(r"&")
+ the_new_cells = []
+ for cell in the_cells: # need to decide if a cell is math or text or mixed
+ cell = cell.strip()
+ cell = r"\\text{" + cell + "}"
+ # now there may be math in text, which we don't want
+ cell = re.sub(r'\\\(',r"}\\(",cell)
+ cell = re.sub(r'\\\)',r"\\)\\text{",cell)
+ cell = re.sub(r"\\text{\s*}","",cell)
+ the_new_cells.append(cell)
+
+ the_new_text = "\\amp\\amp\\amp".join(the_new_cells)
+
+ return "" + the_new_text + "" + "\n"
+
|