]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyxconvert_218.py
bare bones to convert 222
[lyx.git] / lib / lyx2lyx / lyxconvert_218.py
index eb1428cc39dfcd2a72a78215951f52380b6ac9f1..d193a09f4498882079126230b8a06be85e0815e7 100644 (file)
@@ -213,10 +213,12 @@ def remove_oldert(lines):
            break
        j = i+1
        while 1:
-           j = find_tokens(lines, ["\\latex default", "\\begin_inset", "\\layout", "\\end_inset", "\\end_float", "\\the_end"],
+            # \end_inset is for ert inside a tabular cell. The other tokens
+            # are obvious.
+           j = find_tokens(lines, ["\\latex default", "\\layout", "\\begin_inset", "\\end_inset", "\\end_float", "\\the_end"],
                            j)
            if check_token(lines[j], "\\begin_inset"):
-               j = find_end_of_inset(lines, j)
+               j = find_end_of_inset(lines, j)+1
            else:
                break
 
@@ -320,9 +322,13 @@ def remove_oldertinset(lines):
        i = i+1
 
 def is_ert_paragraph(lines, i):
+    if not check_token(lines[i], "\\layout Standard"):
+        return 0
+
     i = find_nonempty_line(lines, i+1)
     if not check_token(lines[i], "\\begin_inset ERT"):
        return 0
+
     j = find_end_of_inset(lines, i)
     k = find_nonempty_line(lines, j+1)
     return check_token(lines[k], "\\layout")
@@ -333,7 +339,7 @@ def combine_ert(lines):
        i = find_token(lines, "\\begin_inset ERT", i)
        if i == -1:
            break
-       j = find_token_backwards(lines,"\\layout", i-1)
+       j = get_paragraph(lines, i)
        count = 0
        text = []
        while is_ert_paragraph(lines, j):
@@ -373,8 +379,12 @@ def remove_figinset(lines):
            break
        j = find_end_of_inset(lines, i)
 
-       lyxwidth = string.split(lines[i])[3]+"pt"
-       lyxheight = string.split(lines[i])[4]+"pt"
+       if ( len(string.split(lines[i])) > 2 ):
+           lyxwidth = string.split(lines[i])[3]+"pt"
+           lyxheight = string.split(lines[i])[4]+"pt"
+       else:
+           lyxwidth = ""
+           lyxheight = ""
 
        filename = get_value(lines, "file", i+1, j)
 
@@ -463,7 +473,7 @@ def change_listof(lines):
        i = find_token(lines, "\\begin_inset LatexCommand \\listof", i)
        if i == -1:
            break
-        type = lines[i][33:-3]
+        type = re.search(r"listof(\w*)", lines[i]).group(1)[:-1]
         lines[i] = "\\begin_inset FloatList "+type
         i = i+1