1 # This file is part of lyx2lyx
2 # Copyright (C) 2004 José Matos <jamatos@lyx.org>
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 """Convert files to the file format generated by lyx 1.0"""
22 from parser_tools import find_re, find_token
25 def obsolete_latex_title(document):
26 "Replace LatexTitle layout with Title."
31 i = find_token(body, "\\layout", i)
35 if body[i].lower().find("latex title") != -1:
36 body[i] = "\\layout Title"
41 def update_tabular(document):
42 "Update from tabular format 3 to 4 if necessary."
45 lyxtable_re = re.compile(r".*\\LyXTable$")
48 i = find_re(lines, lyxtable_re, i)
57 lines[i] = "multicol4"
59 rows = int(lines[i].split()[0])
60 columns = int(lines[i].split()[1])
62 lines[i] = lines[i] + " 0 0 -1 -1 -1 -1"
66 lines[i] = lines[i] + " 0 0"
69 for j in range(columns):
70 lines[i] = lines[i] + " "
73 while lines[i].strip():
74 lines[i] = lines[i] + " 0 0 0"
77 lines[i] = lines[i].strip()
80 supported_versions = ["1.0.%d" % i for i in range(5)] + ["1.0"]
81 convert = [[215, [obsolete_latex_title, update_tabular]]]
85 if __name__ == "__main__":