From 78dc5c62c71be6d5abec867d2d65c5f63ddf55f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matox?= Date: Wed, 21 Aug 2002 17:25:47 +0000 Subject: [PATCH] First step from the 2.17 convertion git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5061 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyxconvert_217.py | 111 ++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 lib/lyx2lyx/lyxconvert_217.py diff --git a/lib/lyx2lyx/lyxconvert_217.py b/lib/lyx2lyx/lyxconvert_217.py new file mode 100644 index 0000000000..875b4f57cb --- /dev/null +++ b/lib/lyx2lyx/lyxconvert_217.py @@ -0,0 +1,111 @@ +# This file is part of lyx2lyx +# Copyright (C) 2002 José Matos +# +# 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 re, string, sys +from parser_tools import * + +bool_table = {"0": "false", "1":"true" } +align_table = {"0": "top", "2": "left", "4": "right", "8": "center"} +use_table = {"0": "none", "1": "parbox"} + +table_meta_re = re.compile(r'') +def update_tabular(lines): + i=0 + while 1: + i = find_token(lines, '\\begin_inset Tabular', i) + if i == -1: + break + + i = i +1 + + # scan table header meta-info + lines[i] = string.replace(lines[i], 'LyXTabular version="1"', 'lyxtabular version="2"') + + j = find_token(lines, '', i) + 1 + if j == 0: + sys.stderr.write( "Error: Bad lyx format i=%d j=%d\n" % (i,j)) + break + + new_table = table_update(lines[i:j]) + tail = lines[j:] + lines[i:] = [] + lines.extend(new_table) + lines.extend(tail) + i = i + len(new_table) + +col_re = re.compile(r'') +cell_re = re.compile(r'') +features_re = re.compile(r'') +row_re = re.compile(r'') + +def table_update(lines): + lines[1] = string.replace(lines[1], '' or lines[i] == '': + del lines[i] + continue + + res = cell_re.match(lines[i]) + if res: + val = res.groups() + lines[i] = '' % ( val[0], align_table[val[1]], align_table[val[2]], bool_table[val[3]], bool_table[val[4]], bool_table[val[5]], bool_table[val[6]], bool_table[val[7]], use_table[val[8]], val[9], val[10]) + + res = row_re.match(lines[i]) + if res: + val = res.groups() + lines[i] = '' % (bool_table[val[0]], bool_table[val[1]], bool_table[val[2]]) + + i = i + 1 + + j = len(col_info) + for i in range(j): + res = col_re.match(col_info[i]) + if res: + val = res.groups() + col_info[i] = '' \ + % ( align_table[val[0]], align_table[val[1]], bool_table[val[2]], bool_table[val[3]], val[4],val[5]) + + return lines[:2] + col_info + lines[2:] + +def convert(header,body): + update_tabular(body) + +if __name__ == "__main__": + pass +