mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Few improvements
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4852 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1bd999fa65
commit
33e6f2089a
@ -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.
|
||||
|
@ -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.
|
||||
@ -166,7 +165,8 @@ def main(argv):
|
||||
for fmt in lst_ft[start:end]:
|
||||
__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__":
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user