}
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
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")
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.
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):
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
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)
return i
return -1
-
def set_comment(lines, number):
x = int(number)
if x < 216: