1 # This file is part of lyx2lyx
2 # Copyright (C) 2003 Jos
\81é Matos <jamatos@fep.up.pt>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 from parser_tools import find_token, find_end_of_inset
20 from string import replace
22 def rm_end_layout(lines):
25 i = find_token(lines, '\\end_layout', i)
32 def begin_layout2layout(lines):
35 i = find_token(lines, '\\begin_layout', i)
39 lines[i] = replace(lines[i], '\\begin_layout', '\\layout')
42 def table_valignment_middle(lines, start, end):
43 for i in range(start, end):
44 if re.search('^<(column|cell) .*valignment="middle".*>$', lines[i]):
45 lines[i] = replace(lines[i], 'valignment="middle"', 'valignment="center"')
47 def valignment_middle(lines):
50 i = find_token(lines, '\\begin_inset Tabular', i)
53 j = find_end_of_inset(lines, i + 1)
55 #this should not happen
56 valignment_middle(lines, i + 1, len(lines))
58 valignment_middle(lines, i + 1, j)
61 def end_document(lines):
62 i = find_token(lines, "\\end_document", 0)
64 lines.append("\\the_end")
66 lines[i] = "\\the_end"
68 def convert(header, body):
70 begin_layout2layout(body)
72 valignment_middle(body)
74 if __name__ == "__main__":