Improve revert of mutlicolumn

Old LyX version can cope with degenerated multicolumn cells spanning only one
column, so these should not cause a conversion of the whole formula to ERT.
Such columns are used to set border lines or alignment for single cells.
This commit is contained in:
Georg Baum 2015-05-17 16:39:14 +02:00
parent 3cd36977c9
commit 69abac9605

View File

@ -1146,9 +1146,21 @@ def revert_mathmulticol(document):
lines = document.body[i:j] lines = document.body[i:j]
lines[0] = lines[0].replace('\\begin_inset Formula', '').lstrip() lines[0] = lines[0].replace('\\begin_inset Formula', '').lstrip()
code = "\n".join(lines) code = "\n".join(lines)
if code.find("\\multicolumn") != -1: converted = False
ert = put_cmd_in_ert(code) k = 0
document.body[i:j+1] = ert n = 0
while n >= 0:
n = code.find("\\multicolumn", k)
# no need to convert degenerated multicolumn cells,
# they work in old LyX versions as "math ERT"
if n != -1 and code.find("\\multicolumn{1}", k) != n:
ert = put_cmd_in_ert(code)
document.body[i:j+1] = ert
converted = True
break
else:
k = n + 12
if converted:
i = find_end_of_inset(document.body, i) i = find_end_of_inset(document.body, i)
else: else:
i = j i = j