2003-02-10 10:27:46 +00:00
|
|
|
# This file is part of lyx2lyx
|
|
|
|
# Copyright (C) 2002 Dekel Tsur <dekel@lyx.org>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
2003-05-22 10:40:57 +00:00
|
|
|
import string
|
2003-06-02 14:16:17 +00:00
|
|
|
from parser_tools import find_token
|
2003-05-22 10:40:57 +00:00
|
|
|
|
2003-03-12 02:39:12 +00:00
|
|
|
def add_end(header):
|
|
|
|
header.append("\\end_header");
|
2003-02-10 10:27:46 +00:00
|
|
|
|
2003-05-22 10:40:57 +00:00
|
|
|
def convert_spaces(lines):
|
|
|
|
for i in range(len(lines)):
|
|
|
|
lines[i] = string.replace(lines[i],"\\SpecialChar ~","\\InsetSpace ~")
|
|
|
|
|
2003-06-01 00:01:50 +00:00
|
|
|
def convert_bibtex(lines):
|
|
|
|
for i in range(len(lines)):
|
|
|
|
lines[i] = string.replace(lines[i],"\\begin_inset LatexCommand \\BibTeX",
|
|
|
|
"\\begin_inset LatexCommand \\bibtex")
|
|
|
|
|
2003-06-02 14:16:17 +00:00
|
|
|
def remove_insetparent(lines):
|
|
|
|
i = 0
|
|
|
|
while 1:
|
|
|
|
i = find_token(lines, "\\begin_inset LatexCommand \\lyxparent", i)
|
|
|
|
if i == -1:
|
|
|
|
break
|
|
|
|
del lines[i:i+3]
|
|
|
|
|
2003-02-10 10:27:46 +00:00
|
|
|
def convert(header, body):
|
2003-03-12 02:39:12 +00:00
|
|
|
add_end(header)
|
2003-05-22 10:40:57 +00:00
|
|
|
convert_spaces(body)
|
2003-06-01 00:01:50 +00:00
|
|
|
convert_bibtex(body)
|
2003-06-02 14:16:17 +00:00
|
|
|
remove_insetparent(body)
|
2003-02-10 10:27:46 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
pass
|