mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 20:32:49 +00:00
8d914e2c52
exact match * parser_tools.py (find_token2): rename to find_token_exact and make it work for tokens with spaces * lyx_1_4.py (revert_box, convert_collapsable, revert_bibtopic, convert_float): use find_token(s)_exact instead of find_token(s). This does not match "FloatList" when "Float" is searched (bug 2245) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13410 a592a061-630c-0410-9148-cb99ea01b6c8
101 lines
3.0 KiB
Python
101 lines
3.0 KiB
Python
# This file is part of lyx2lyx
|
|
# -*- coding: iso-8859-1 -*-
|
|
# Copyright (C) 2002 Dekel Tsur <dekel@lyx.org>
|
|
# Copyright (C) 2004 José Matos <jamatos@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.
|
|
|
|
import string
|
|
import re
|
|
from parser_tools import find_token, find_end_of_inset, get_value,\
|
|
find_token_exact, del_token
|
|
|
|
def change_insetgraphics(file):
|
|
lines = file.body
|
|
i = 0
|
|
while 1:
|
|
i = find_token(lines, "\\begin_inset Graphics", i)
|
|
if i == -1:
|
|
break
|
|
j = find_end_of_inset(lines, i)
|
|
|
|
lines[i] = "\\begin_inset Graphics"
|
|
|
|
if get_value(lines, "display", i, j) == "default":
|
|
j = del_token(lines, "display", i, j)
|
|
if get_value(lines, "rotateOrigin", i, j) == "leftBaseline":
|
|
j = del_token(lines, "rotateOrigin", i, j)
|
|
|
|
k = find_token_exact(lines, "rotate", i, j)
|
|
if k != -1:
|
|
del lines[k]
|
|
j = j-1
|
|
else:
|
|
j = del_token(lines, "rotateAngle", i, j)
|
|
|
|
k = find_token_exact(lines, "size_type", i, j)
|
|
if k == -1:
|
|
k = find_token_exact(lines, "size_kind", i, j)
|
|
if k != -1:
|
|
size_type = string.split(lines[k])[1]
|
|
del lines[k]
|
|
j = j-1
|
|
if size_type in ["0", "original"]:
|
|
j = del_token(lines, "width", i, j)
|
|
j = del_token(lines, "height", i, j)
|
|
j = del_token(lines, "scale", i, j)
|
|
elif size_type in ["2", "scale"]:
|
|
j = del_token(lines, "width", i, j)
|
|
j = del_token(lines, "height", i, j)
|
|
if get_value(lines, "scale", i, j) == "100":
|
|
j = del_token(lines, "scale", i, j)
|
|
else:
|
|
j = del_token(lines, "scale", i, j)
|
|
|
|
k = find_token_exact(lines, "lyxsize_type", i, j)
|
|
if k == -1:
|
|
k = find_token_exact(lines, "lyxsize_kind", i, j)
|
|
if k != -1:
|
|
lyxsize_type = string.split(lines[k])[1]
|
|
del lines[k]
|
|
j = j-1
|
|
j = del_token(lines, "lyxwidth", i, j)
|
|
j = del_token(lines, "lyxheight", i, j)
|
|
if lyxsize_type not in ["2", "scale"] or \
|
|
get_value(lines, "lyxscale", i, j) == "100":
|
|
j = del_token(lines, "lyxscale", i, j)
|
|
|
|
i = i+1
|
|
|
|
|
|
def change_tabular(file):
|
|
lines = file.body
|
|
i = 0
|
|
while 1:
|
|
i = find_token(lines, "<column", i)
|
|
if i == -1:
|
|
break
|
|
if not re.search('width="0pt"', lines[i]):
|
|
lines[i] = re.sub(' alignment=".*?"',' alignment="block"',lines[i])
|
|
i = i+1
|
|
|
|
|
|
convert = [[221, [change_insetgraphics, change_tabular]]]
|
|
revert = []
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pass
|