]> git.lyx.org Git - features.git/commitdiff
Improve revert of mutlicolumn
authorGeorg Baum <baum@lyx.org>
Sun, 17 May 2015 14:39:14 +0000 (16:39 +0200)
committerGeorg Baum <baum@lyx.org>
Sun, 17 May 2015 14:39:14 +0000 (16:39 +0200)
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.

lib/lyx2lyx/lyx_2_2.py

index bca3b56b3be519cff516796ec38a5882d2d00875..e225abf977ee43b9818b744642b3060a8fe63405 100644 (file)
@@ -1146,9 +1146,21 @@ def revert_mathmulticol(document):
         lines = document.body[i:j]
         lines[0] = lines[0].replace('\\begin_inset Formula', '').lstrip()
         code = "\n".join(lines)
-        if code.find("\\multicolumn") != -1:
-            ert = put_cmd_in_ert(code)
-            document.body[i:j+1] = ert
+        converted = False
+        k = 0
+        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)
         else:
             i = j