old ERT insets should just be ignored

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4949 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2002-08-12 21:48:47 +00:00
parent 6894fa6008
commit cbbfb29048
2 changed files with 12 additions and 19 deletions

View File

@ -228,7 +228,7 @@ def remove_oldert(lines):
# as similar as posible to the lyx format # as similar as posible to the lyx format
new2 = [""] new2 = [""]
new2.append(line) new2.append(line)
else: elif not check_token(line, "\\latex"):
tmp.append(line) tmp.append(line)
if is_empty(tmp): if is_empty(tmp):
@ -268,27 +268,19 @@ def remove_oldert(lines):
lines[i:j+1] = new lines[i:j+1] = new
i = i+1 i = i+1
def convert_ertinset(lines): def remove_oldertinset(lines):
i = 0 i = 0
while 1: while 1:
i = find_token(lines, "\\begin_inset ERT", i) i = find_token(lines, "\\begin_inset ERT", i)
if i == -1: if i == -1:
break break
j = find_token(lines, "collapsed", i+1)
if string.split(lines[j])[1] == "true":
status = "Collapsed"
else:
status = "Open"
lines[j] = "status " + status
# Remove font commands
j = find_end_of_inset(lines, i) j = find_end_of_inset(lines, i)
new = [] k = find_token(lines, "\\layout", i+1)
for line in lines[i:j]: l = get_paragraph(lines, i)
if not font_rexp.match(line) and not check_token(line, "\\latex"): if lines[k] == lines[l]: # same layout
new.append(line) k = k+1
lines[i:j] = new new = lines[k:j]
lines[i:j+1] = new
i = i+1 i = i+1
def is_ert_paragraph(lines, i): def is_ert_paragraph(lines, i):
@ -409,7 +401,7 @@ def convert(header, body):
language = "english" language = "english"
change_preamble(header) change_preamble(header)
convert_ertinset(body) remove_oldertinset(body)
remove_oldert(body) remove_oldert(body)
combine_ert(body) combine_ert(body)
remove_oldminipage(body) remove_oldminipage(body)

View File

@ -92,14 +92,15 @@ def get_paragraph(lines, i):
def find_end_of_inset(lines, i): def find_end_of_inset(lines, i):
count = 1 count = 1
i = i+1 i = i+1
while count > 0: while 1:
i = find_tokens(lines, ["\\end_inset", "\\begin_inset"], i) i = find_tokens(lines, ["\\end_inset", "\\begin_inset"], i)
if check_token(lines[i], "\\begin_inset"): if check_token(lines[i], "\\begin_inset"):
count = count+1 count = count+1
else: else:
count = count-1 count = count-1
i = i+1 if count == 0:
return i return i
i = i+1
def is_nonempty_line(line): def is_nonempty_line(line):
return line != " "*len(line) return line != " "*len(line)