]> git.lyx.org Git - features.git/commitdiff
Few improvements
authorDekel Tsur <dekelts@tau.ac.il>
Sat, 3 Aug 2002 10:31:31 +0000 (10:31 +0000)
committerDekel Tsur <dekelts@tau.ac.il>
Sat, 3 Aug 2002 10:31:31 +0000 (10:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4852 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/lyx2lyx/lyx2lyx
lib/lyx2lyx/lyxconvert_218.py
lib/lyx2lyx/parser_tools.py

index e99ae2f90170ff87cf9a24745e026370ce105ec3..f3193b316577a74e00542911bd8e4af16d4a84aa 100644 (file)
@@ -1,3 +1,9 @@
+2002-08-03  Dekel Tsur  <dekelts@tau.ac.il>
+
+       * lyx2lyx/lyxconvert_218.py (remove_oldert): Few fixes.
+
+       * lyx2lyx/lyx2lyx: Change the comment at the top of the lyx file
+
 2002-08-02  Dekel Tsur  <dekelts@tau.ac.il>
 
        * lyx2lyx/lyxconvert_218.py: Convert ERT and figinsets.
index 51e830babd553325afd364c4de986012c3de1826..7960ffd27b2ab55353009ba08114ab7bb8777c41 100755 (executable)
@@ -17,7 +17,7 @@
 
 import getopt, sys, string, re
 from error import error, warning
-from parser_tools import set_format
+from parser_tools import set_comment, set_format
 
 version = "0.0.2"
 
@@ -38,8 +38,7 @@ opt.quiet = 0
 format = re.compile(r"(\d)[\.,]?(\d\d)")
 fileformat = re.compile(r"\\lyxformat\s*(\S*)")
 lst_ft = ["210", "215", "216", "217", "218", "220"]
-format_name = {"210" : "2.10", "215":"2.15", "216": "2.16",
-               "217" : "2.17", "218":"218" , "220":"220"}
+
 def usage():
     print """Usage: lyx2lyx [options] file1
 Convert old lyx file <file1> to newer format.
@@ -164,9 +163,10 @@ def main(argv):
     end = lst_ft.index(opt.end)
 
     for fmt in lst_ft[start:end]:
-        __import__("lyxconvert_" + fmt).convert(header,body)
+       __import__("lyxconvert_" + fmt).convert(header,body)
 
-    set_format(header,format_name[opt.end])
+    set_comment(header, opt.end)
+    set_format(header, opt.end)
     write_file(opt.output, header, body)
     
 if __name__ == "__main__":
index 42f9161a45593f0fcb8cd3bea4d35fce7e2493df..7e9e26acc4e454affb18593e586ad60d66ddd2fb 100644 (file)
@@ -171,10 +171,8 @@ def remove_oldert(lines):
        i = find_tokens(lines, ["\\latex latex", "\\layout LaTeX"], i)
        if i == -1:
            break
-       j = find_tokens(lines, ["\\latex default", "\\layout", "\\end_float"],
+       j = find_tokens(lines, ["\\latex default", "\\layout", "\\end_float", "\\the_end"],
                        i+1)
-       if j == -1:
-           j = len(lines)-1
        if check_token(lines[j], "\\layout"):
            while j-1 >= 0 and check_token(lines[j-1], "\\begin_deeper"):
                j = j-1
@@ -257,7 +255,8 @@ def combine_ert(lines):
                break
 
        if count >= 2:
-           lines[i+1:k] = text
+           j = find_token(lines, "\\layout", i+1)
+           lines[j:k] = text
 
        i = i+1
        
index f75eeac204cd6f584affb942721e037986b3eaee..ffe8cfcee40473f7fbc199f698766c24e066e7d4 100644 (file)
@@ -77,6 +77,23 @@ def find_nonempty_line(lines, start, end = 0):
            return i
     return -1
 
+
+def set_comment(lines, number):
+    x = int(number)
+    if x < 216:
+       # It is not worth the trouble to handle this case
+       return
+    elif x < 220:
+       version = "1.1"
+    else:
+       version = "1.2"
+
+    lines[0] = "#LyX %s created this file. For more info see http://www.lyx.org/" % version
+    if lines[1][0] == '#':
+       del lines[1]
+
 def set_format(lines, number):
+    if int(number) <= 217:
+       number = float(number)/100
     i = find_token(lines, "\\lyxformat", 0)
     lines[i] = "\\lyxformat %s" % number