mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Work with nested tabulars
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5189 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ebfa493a41
commit
e579a794e2
@ -1,3 +1,7 @@
|
|||||||
|
2002-08-31 Dekel Tsur <dekelts@tau.ac.il>
|
||||||
|
|
||||||
|
* lyx2lyx/lyxconvert_218.py (update_tabular): Work with nested tabulars
|
||||||
|
|
||||||
2002-08-29 John Levon <levon@movementarian.org>
|
2002-08-29 John Levon <levon@movementarian.org>
|
||||||
|
|
||||||
* images/math/: add AMS nrel
|
* images/math/: add AMS nrel
|
||||||
|
@ -404,20 +404,20 @@ def update_tabular(lines):
|
|||||||
if i == -1:
|
if i == -1:
|
||||||
break
|
break
|
||||||
|
|
||||||
# scan table header meta-info
|
j = find_end_of_tabular(lines, i+1)
|
||||||
lines[i+1] = string.replace(lines[i+1], 'version="2"', 'version="3"')
|
|
||||||
|
|
||||||
j = find_token(lines, '</lyxtabular>', i)
|
|
||||||
if j == -1:
|
if j == -1:
|
||||||
break
|
break
|
||||||
|
|
||||||
for k in xrange(i+2,j):
|
for k in xrange(i+1,j):
|
||||||
if check_token(lines[k], "<column"):
|
if check_token(lines[k], "<lyxtabular"):
|
||||||
lines[k] = string.replace(lines[k], 'width=""', 'width="0pt"')
|
lines[k] = string.replace(lines[k], 'version="2"', 'version="3"')
|
||||||
|
elif check_token(lines[k], "<column"):
|
||||||
|
lines[k] = string.replace(lines[k], 'width=""', 'width="0pt"')
|
||||||
|
|
||||||
if line_re.match(lines[k]):
|
if line_re.match(lines[k]):
|
||||||
lines[k] = re.sub(attr_re, "", lines[k])
|
lines[k] = re.sub(attr_re, "", lines[k])
|
||||||
|
|
||||||
i = i+1
|
i = j+1
|
||||||
|
|
||||||
def change_preamble(lines):
|
def change_preamble(lines):
|
||||||
i = find_token(lines, "\\use_amsmath", 0)
|
i = find_token(lines, "\\use_amsmath", 0)
|
||||||
|
@ -106,29 +106,43 @@ def get_next_paragraph(lines, i):
|
|||||||
return i
|
return i
|
||||||
i = find_end_of_inset(lines, i)
|
i = find_end_of_inset(lines, i)
|
||||||
|
|
||||||
# Finds the matching \end_inset
|
def find_end_of(lines, i, start_token, end_token):
|
||||||
def find_end_of_inset(lines, i):
|
|
||||||
count = 1
|
count = 1
|
||||||
while 1:
|
n = len(lines)
|
||||||
i = find_tokens(lines, ["\\end_inset", "\\begin_inset"], i+1)
|
while i < n:
|
||||||
if check_token(lines[i], "\\begin_inset"):
|
i = find_tokens(lines, [end_token, start_token], i+1)
|
||||||
|
if check_token(lines[i], start_token):
|
||||||
count = count+1
|
count = count+1
|
||||||
else:
|
else:
|
||||||
count = count-1
|
count = count-1
|
||||||
if count == 0:
|
if count == 0:
|
||||||
return i
|
return i
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# Finds the matching \end_inset
|
||||||
|
def find_beginning_of(lines, i, start_token, end_token):
|
||||||
|
count = 1
|
||||||
|
n = len(lines)
|
||||||
|
while i < n:
|
||||||
|
i = find_tokens_backwards(lines, [start_token, end_token], i-1)
|
||||||
|
if check_token(lines[i], end_token):
|
||||||
|
count = count+1
|
||||||
|
else:
|
||||||
|
count = count-1
|
||||||
|
if count == 0:
|
||||||
|
return i
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# Finds the matching \end_inset
|
||||||
|
def find_end_of_inset(lines, i):
|
||||||
|
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
|
||||||
|
|
||||||
# Finds the matching \end_inset
|
# Finds the matching \end_inset
|
||||||
def find_beginning_of_inset(lines, i):
|
def find_beginning_of_inset(lines, i):
|
||||||
count = 1
|
return find_beginning_of(lines, i, "\\begin_inset", "\\end_inset")
|
||||||
while 1:
|
|
||||||
i = find_tokens_backwards(lines, ["\\end_inset", "\\begin_inset"], i-1)
|
def find_end_of_tabular(lines, i):
|
||||||
if check_token(lines[i], "\\end_inset"):
|
return find_end_of(lines, i, "<lyxtabular", "</lyxtabular")
|
||||||
count = count+1
|
|
||||||
else:
|
|
||||||
count = count-1
|
|
||||||
if count == 0:
|
|
||||||
return i
|
|
||||||
|
|
||||||
def is_nonempty_line(line):
|
def is_nonempty_line(line):
|
||||||
return line != " "*len(line)
|
return line != " "*len(line)
|
||||||
|
Loading…
Reference in New Issue
Block a user