Small changes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4929 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2002-08-10 13:34:57 +00:00
parent ac7459f7ac
commit 7edacbcbea
3 changed files with 22 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2002-08-10 Dekel Tsur <dekelts@tau.ac.il>
* lyx2lyx/parser_tools.py (get_paragraph): Fixed.
* lyx2lyx/lyxconvert_218.py (convert_ertinset): Remove font commands.
2002-08-08 Herbert Voss <voss@perce.de> 2002-08-08 Herbert Voss <voss@perce.de>
* ui/default.ui: put gather into math menu * ui/default.ui: put gather into math menu

View File

@ -190,7 +190,7 @@ def remove_oldert(lines):
j = find_tokens(lines, ["\\latex default", "\\begin_inset", "\\layout", "\\end_float", "\\the_end"], j = find_tokens(lines, ["\\latex default", "\\begin_inset", "\\layout", "\\end_float", "\\the_end"],
j) j)
if check_token(lines[j], "\\begin_inset"): if check_token(lines[j], "\\begin_inset"):
j = skip_inset(lines, j) j = find_end_of_inset(lines, j)
else: else:
break break
@ -243,7 +243,7 @@ def remove_oldert(lines):
new = new+ert_begin+tmp+["\\end_inset ", ""] new = new+ert_begin+tmp+["\\end_inset ", ""]
if inset: if inset:
k3 = find_token(lines, "\\end_inset", k2+1) k3 = find_end_of_inset(lines, k2)
new = new+[""]+lines[k2:k3+1]+[""] # Put an empty line after \end_inset new = new+[""]+lines[k2:k3+1]+[""] # Put an empty line after \end_inset
k = k3+1 k = k3+1
# Skip the empty line after \end_inset # Skip the empty line after \end_inset
@ -280,13 +280,22 @@ def convert_ertinset(lines):
else: else:
status = "Open" status = "Open"
lines[j] = "status " + status lines[j] = "status " + status
# Remove font commands
j = find_end_of_inset(lines, i)
new = []
for line in lines[i:j]:
if not font_rexp.match(line) and not check_token(line, "\\latex"):
new.append(line)
lines[i:j] = new
i = i+1 i = i+1
def is_ert_paragraph(lines, i): def is_ert_paragraph(lines, i):
i = find_nonempty_line(lines, i+1) i = find_nonempty_line(lines, i+1)
if not check_token(lines[i], "\\begin_inset ERT"): if not check_token(lines[i], "\\begin_inset ERT"):
return 0 return 0
j = find_token(lines, "\\end_inset", i) j = find_end_of_inset(lines, i)
k = find_nonempty_line(lines, j+1) k = find_nonempty_line(lines, j+1)
return check_token(lines[k], "\\layout") return check_token(lines[k], "\\layout")
@ -334,7 +343,7 @@ def remove_figinset(lines):
i = find_token(lines, "\\begin_inset Figure", i) i = find_token(lines, "\\begin_inset Figure", i)
if i == -1: if i == -1:
break break
j = find_token(lines, "\\end_inset", i+1) j = find_end_of_inset(lines, i)
lyxwidth = string.split(lines[i])[3]+"pt" lyxwidth = string.split(lines[i])[3]+"pt"
lyxheight = string.split(lines[i])[4]+"pt" lyxheight = string.split(lines[i])[4]+"pt"

View File

@ -74,6 +74,7 @@ def get_value(lines, token, start, end = 0):
return string.split(lines[i])[1] return string.split(lines[i])[1]
# Finds the paragraph that contains line i. # Finds the paragraph that contains line i.
import sys
def get_paragraph(lines, i): def get_paragraph(lines, i):
while 1: while 1:
i = find_tokens_backwards(lines, ["\\end_inset", "\\layout"], i) i = find_tokens_backwards(lines, ["\\end_inset", "\\layout"], i)
@ -81,15 +82,14 @@ def get_paragraph(lines, i):
return i return i
count = 1 count = 1
while count > 0: while count > 0:
i = find_tokens_backwards(lines, ["\\end_inset", "\\begin_inset"], i) i = find_tokens_backwards(lines, ["\\end_inset", "\\begin_inset"], i-1)
if check_token(lines[i], "\\end_inset"): if check_token(lines[i], "\\end_inset"):
count = count+1 count = count+1
else: else:
count = count-1 count = count-1
i = i-1
# Finds the matching \end_inset # Finds the matching \end_inset
def skip_inset(lines, i): def find_end_of_inset(lines, i):
count = 1 count = 1
i = i+1 i = i+1
while count > 0: while count > 0: