mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
- Fix ert conversion
- Convert old ERT insets git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4875 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d1813576e4
commit
a99f3cc3c6
@ -185,8 +185,15 @@ def remove_oldert(lines):
|
|||||||
i = find_tokens(lines, ["\\latex latex", "\\layout LaTeX"], i)
|
i = find_tokens(lines, ["\\latex latex", "\\layout LaTeX"], i)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
break
|
break
|
||||||
j = find_tokens(lines, ["\\latex default", "\\layout", "\\end_float", "\\the_end"],
|
j = i+1
|
||||||
i+1)
|
while 1:
|
||||||
|
j = find_tokens(lines, ["\\latex default", "\\begin_inset", "\\layout", "\\end_float", "\\the_end"],
|
||||||
|
j)
|
||||||
|
if check_token(lines[j], "\\begin_inset"):
|
||||||
|
j = skip_inset(lines, j)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
if check_token(lines[j], "\\layout"):
|
if check_token(lines[j], "\\layout"):
|
||||||
while j-1 >= 0 and check_token(lines[j-1], "\\begin_deeper"):
|
while j-1 >= 0 and check_token(lines[j-1], "\\begin_deeper"):
|
||||||
j = j-1
|
j = j-1
|
||||||
@ -261,6 +268,20 @@ def remove_oldert(lines):
|
|||||||
lines[i:j+1] = new
|
lines[i:j+1] = new
|
||||||
i = i+1
|
i = i+1
|
||||||
|
|
||||||
|
def convert_ertinset(lines):
|
||||||
|
i = 0
|
||||||
|
while 1:
|
||||||
|
i = find_token(lines, "\\begin_inset ERT", i)
|
||||||
|
if i == -1:
|
||||||
|
break
|
||||||
|
j = find_token(lines, "collapsed", i+1)
|
||||||
|
if string.split(lines[j])[1] == "true":
|
||||||
|
status = "Collapsed"
|
||||||
|
else:
|
||||||
|
status = "Open"
|
||||||
|
lines[j] = "status " + status
|
||||||
|
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"):
|
||||||
@ -379,6 +400,7 @@ def convert(header, body):
|
|||||||
language = "english"
|
language = "english"
|
||||||
|
|
||||||
change_preamble(header)
|
change_preamble(header)
|
||||||
|
convert_ertinset(body)
|
||||||
remove_oldert(body)
|
remove_oldert(body)
|
||||||
combine_ert(body)
|
combine_ert(body)
|
||||||
remove_oldminipage(body)
|
remove_oldminipage(body)
|
||||||
|
@ -88,6 +88,18 @@ def get_paragraph(lines, i):
|
|||||||
count = count-1
|
count = count-1
|
||||||
i = i-1
|
i = i-1
|
||||||
|
|
||||||
|
# Finds the matching \end_inset
|
||||||
|
def skip_inset(lines, i):
|
||||||
|
count = 1
|
||||||
|
i = i+1
|
||||||
|
while count > 0:
|
||||||
|
i = find_tokens(lines, ["\\end_inset", "\\begin_inset"], i)
|
||||||
|
if check_token(lines[i], "\\begin_inset"):
|
||||||
|
count = count+1
|
||||||
|
else:
|
||||||
|
count = count-1
|
||||||
|
i = i+1
|
||||||
|
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