git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5027 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2002-08-19 19:51:01 +00:00
parent 72f30959c1
commit 839002cb96
2 changed files with 32 additions and 19 deletions

View File

@ -47,7 +47,7 @@ floats = {
}
font_tokens = ["\\family", "\\series", "\\shape", "\\size", "\\emph",
"\\bar", "\\noun", "\\color", "\\lang"]
"\\bar", "\\noun", "\\color", "\\lang", "\\latex"]
#
# Change \begin_float .. \end_float into \begin_inset Float .. \end_inset
@ -59,7 +59,9 @@ def remove_oldfloat(lines, language):
i = find_token(lines, "\\begin_float", i)
if i == -1:
break
# There are no nested floats, so finding the end of the float is simple
j = find_token(lines, "\\end_float", i+1)
floattype = string.split(lines[i])[1]
if not floats.has_key(floattype):
sys.stderr.write("Error! Unknown float type "+floattype+"\n")
@ -70,11 +72,12 @@ def remove_oldfloat(lines, language):
while check_token(lines[i2], "\\end_deeper"):
i2 = i2+1
if i2 > i+1:
j2 = find_token(lines, "\\layout", j+1)
j2 = get_next_paragraph(lines, j+1)
lines[j2:j2] = ["\\end_deeper "]*(i2-(i+1))
new = floats[floattype]+[""]
new = new+lines[i2:j]+["\\end_inset ", ""]
# After a float, all font attribute are reseted.
# We need to output '\foo default' for every attribute foo
# whose value is not default before the float.
@ -92,11 +95,11 @@ def remove_oldfloat(lines, language):
flag = 1
new.append("")
if token == "\\lang":
new.append(token+" "+language+" ")
new.append(token+" "+language)
else:
new.append(token+" default ")
lines[i:j+1]= new
lines[i:j+1] = new
i = i+1
def remove_oldminipage(lines):
@ -401,12 +404,12 @@ def convert(header, body):
language = "english"
change_preamble(header)
remove_oldertinset(body)
remove_oldert(body)
combine_ert(body)
remove_oldminipage(body)
remove_oldfloat(body, language)
remove_figinset(body)
remove_oldertinset(body)
remove_oldert(body)
combine_ert(body)
if __name__ == "__main__":
pass

View File

@ -74,33 +74,44 @@ def get_value(lines, token, start, end = 0):
return string.split(lines[i])[1]
# Finds the paragraph that contains line i.
import sys
def get_paragraph(lines, i):
while 1:
i = find_tokens_backwards(lines, ["\\end_inset", "\\layout"], i)
if check_token(lines[i], "\\layout"):
return i
count = 1
while count > 0:
i = find_tokens_backwards(lines, ["\\end_inset", "\\begin_inset"], i-1)
if check_token(lines[i], "\\end_inset"):
count = count+1
else:
count = count-1
i = find_beginning_of_inset(lines, i)
# Finds the paragraph after the paragraph that contains line i.
def get_next_paragraph(lines, i):
while 1:
i = find_tokens(lines, ["\\begin_inset", "\\layout"], i)
if check_token(lines[i], "\\layout"):
return i
i = find_end_of_inset(lines, i)
# Finds the matching \end_inset
def find_end_of_inset(lines, i):
count = 1
i = i+1
while 1:
i = find_tokens(lines, ["\\end_inset", "\\begin_inset"], i)
i = find_tokens(lines, ["\\end_inset", "\\begin_inset"], i+1)
if check_token(lines[i], "\\begin_inset"):
count = count+1
else:
count = count-1
if count == 0:
return i
i = i+1
# Finds the matching \end_inset
def find_beginning_of_inset(lines, i):
count = 1
while 1:
i = find_tokens_backwards(lines, ["\\end_inset", "\\begin_inset"], i-1)
if check_token(lines[i], "\\end_inset"):
count = count+1
else:
count = count-1
if count == 0:
return i
def is_nonempty_line(line):
return line != " "*len(line)
@ -113,7 +124,6 @@ def find_nonempty_line(lines, start, end = 0):
return i
return -1
def set_comment(lines, number):
x = int(number)
if x < 216: