]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyxconvert_216.py
Modify the InsetBox format to always start 'Box'.
[lyx.git] / lib / lyx2lyx / lyxconvert_216.py
index 66c1aa059846525e584765a5b248f2d3bb6cab2e..aff343beb52827f099fc6a9c858ed808c3499865 100644 (file)
@@ -46,7 +46,7 @@ def update_tabular(lines):
         lines.insert(i, '<Features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (head[2],head[3],head[4],head[5],head[6],head[7]))
 
         i = i +1
-        
+
         row_info = []
         cont_row = []
         for j in range(rows):
@@ -78,7 +78,7 @@ def update_tabular(lines):
         del lines[i]
         if not lines[i]:
             del lines[i]
-        
+
         # Read cells
         l = 0
         cell_content = []
@@ -99,7 +99,7 @@ def update_tabular(lines):
                     # the end variable refers to cell end, not to file end.
                     end = find_tokens(lines, ['\\layout','\\the_end','\\end_deeper','\\end_float'], i)
                 else:
-                    end = find_token(lines, '\\newline ', i)
+                    end = find_token(lines, '\\newline', i)
 
                 if end == -1:
                     sys.stderr.write("Malformed lyx file\n")
@@ -111,7 +111,7 @@ def update_tabular(lines):
                     del lines[i]
                     end = end -1
 
-                if lines[i] == '\\newline ':
+                if string.find(lines[i],'\\newline') != -1:
                     del lines[i]
                 l = l + 1
 
@@ -150,15 +150,15 @@ def update_tabular(lines):
                     paragraph = []
                     if cell_info[m][4] == '1':
                         l = j
-                        paragraph.extend(cell_content[j][k])
+                        paragraph = paragraph + cell_content[j][k]
                         while cell_info[m][4] == '1':
                             m = m + columns
                             l = l + 1
-                            paragraph.extend(cell_content[l][k])
+                            paragraph = paragraph + cell_content[l][k]
                     else:
                         paragraph = cell_content[j][k]
-                    tmp.extend(set_paragraph_properties(paragraph, prop_dict))
-                
+                    tmp = tmp + set_paragraph_properties(paragraph, prop_dict)
+
                 tmp.append('\\end_inset ')
                 tmp.append('</Cell>')
                 tmp.append('</Column>')
@@ -169,10 +169,7 @@ def update_tabular(lines):
         tmp.append('\\end_inset ')
         tmp.append('')
         tmp.append('')
-        tail = lines[i:]
-        lines[i:] = []
-        lines.extend(tmp)
-        lines.extend(tail)
+        lines[i:i] = tmp
 
         i = i + len(tmp)
 
@@ -220,6 +217,8 @@ def set_paragraph_properties(lines, prop_dict):
 
     # remove final char properties
     n = len(lines)
+    changed_prop = []
+
     while n:
         n = n - 1
         if not lines[n]:
@@ -230,6 +229,7 @@ def set_paragraph_properties(lines, prop_dict):
             result = prop_exp.match(lines[n])
             prop = result.group(1)
             if prop in properties:
+                changed_prop.append(prop)
                 prop_dict[prop] = result.group(2)
                 del lines[n]
                 continue
@@ -240,9 +240,16 @@ def set_paragraph_properties(lines, prop_dict):
                 lines.append('')
         break
 
+    for line in lines[end:]:
+        if line[:1] == '\\':
+            result = prop_exp.match(line)
+            prop = result.group(1)
+            if prop in properties and prop not in changed_prop:
+                prop_dict[prop] = result.group(2)
+
     if not lines[start:] and not lines[end:]:
         return []
-    
+
     result = lines[:start] + aux[:] + lines[end:]
     if insert and result[0] != '':
         return [''] + result[:]
@@ -256,7 +263,8 @@ def update_language(header):
         header.append('\\language english')
         return
     # This is the lyx behaviour: defaults to english
-    header[i] = '\\language english'
+    if string.split(header[i])[1] == 'default':
+        header[i] = '\\language english'
     return
 
 def convert(header,body):