]> git.lyx.org Git - lyx.git/blob - lib/lyx2lyx/lyxrevert_223.py
Modify the InsetBox format to always start 'Box'.
[lyx.git] / lib / lyx2lyx / lyxrevert_223.py
1 # This file is part of lyx2lyx
2 # Copyright (C) 2003 Jos\81é Matos <jamatos@fep.up.pt>
3 #
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.
8 #
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.
13 #
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.
17
18 import string
19 from parser_tools import find_token
20
21 def rm_end_header(lines):
22     i = find_token(lines, "\\end_header", 0)
23     if i == -1:
24         return
25     del lines[i]
26
27 def convert_spaces(lines):
28     for i in range(len(lines)):
29         lines[i] = string.replace(lines[i],"\\InsetSpace ~", "\\SpecialChar ~")
30
31 def convert_bibtex(lines):
32     for i in range(len(lines)):
33         lines[i] = string.replace(lines[i], "\\begin_inset LatexCommand \\bibtex",
34                                   "\\begin_inset LatexCommand \\BibTeX")
35
36 def rm_tracking_changes(lines):
37     i = find_token(lines, "\\author", 0)
38     if i != -1:
39         del lines[i]
40
41     i = find_token(lines, "\\tracking_changes", 0)
42     if i == -1:
43         return
44     del lines[i]
45
46 def rm_body_changes(lines):
47     i = 0
48     while 1:
49         i = find_token(lines, "\\change_", i)
50         if i == -1:
51             return
52
53         del lines[i]
54
55 def convert(header, body):
56     rm_end_header(header)
57     convert_spaces(body)
58     convert_bibtex(body)
59     rm_tracking_changes(header)
60     rm_body_changes(body)
61
62 if __name__ == "__main__":
63     pass