]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyxconvert_215.py
Revert, revert, revert. Sorry about that, y'all.
[lyx.git] / lib / lyx2lyx / lyxconvert_215.py
index 1dbc589bd26e44955dd0a0261926ec0d26303b94..91990c5802cd5bcec47d3c77ca61c1159052665d 100644 (file)
@@ -107,13 +107,45 @@ def remove_vcid(lines):
     if i != -1:
         del lines[i]
 
+def first_layout(lines):
+    while (lines[0] == ""):
+        del lines[0]
+    if lines[0][:7] != "\\layout":
+        lines[:0] = ["\\layout Standard"]
+
+def remove_space_in_units(lines):
+    margins = ["\\topmargin","\\rightmargin",
+               "\\leftmargin","\\bottommargin"]
+
+    unit_rexp = re.compile(r'[^ ]* (.*) (.*)')
+
+    begin_preamble = find_token(lines,"\\begin_preamble", 0)
+    end_preamble = find_token(lines, "\\end_preamble", 0)
+    for margin in margins:
+        i = 0
+        while 1:
+            i = find_token(lines, margin, i)
+            if i == -1:
+                break
+
+            if i > begin_preamble and i < end_preamble:
+                i = i + 1
+                continue
+
+            result = unit_rexp.search(lines[i])
+            if result:
+                lines[i] = margin + " " + result.group(1) + result.group(2)
+            i = i + 1
+
 def convert(header,body):
+    first_layout(body)
     remove_vcid(header)
     remove_cursor(body)
     update_toc(body)
     replace_protected_separator(body)
     merge_formula_inset(body)
     update_tabular(body)
+    remove_space_in_units(header)    
 
 if __name__ == "__main__":
     pass