From: Dekel Tsur Date: Mon, 12 Aug 2002 21:48:47 +0000 (+0000) Subject: old ERT insets should just be ignored X-Git-Tag: 1.6.10~18593 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=cbbfb29048f9d127d4dda3e684ad1895d0d3bb42;p=features.git old ERT insets should just be ignored git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4949 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/lyx2lyx/lyxconvert_218.py b/lib/lyx2lyx/lyxconvert_218.py index 9a6db44ba7..89eb0a365d 100644 --- a/lib/lyx2lyx/lyxconvert_218.py +++ b/lib/lyx2lyx/lyxconvert_218.py @@ -228,7 +228,7 @@ def remove_oldert(lines): # as similar as posible to the lyx format new2 = [""] new2.append(line) - else: + elif not check_token(line, "\\latex"): tmp.append(line) if is_empty(tmp): @@ -268,27 +268,19 @@ def remove_oldert(lines): lines[i:j+1] = new i = i+1 -def convert_ertinset(lines): +def remove_oldertinset(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 - - # 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 - + k = find_token(lines, "\\layout", i+1) + l = get_paragraph(lines, i) + if lines[k] == lines[l]: # same layout + k = k+1 + new = lines[k:j] + lines[i:j+1] = new i = i+1 def is_ert_paragraph(lines, i): @@ -409,7 +401,7 @@ def convert(header, body): language = "english" change_preamble(header) - convert_ertinset(body) + remove_oldertinset(body) remove_oldert(body) combine_ert(body) remove_oldminipage(body) diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index ac78b93a03..b01a8c83b1 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -92,14 +92,15 @@ def get_paragraph(lines, i): def find_end_of_inset(lines, i): count = 1 i = i+1 - while count > 0: + while 1: i = find_tokens(lines, ["\\end_inset", "\\begin_inset"], i) if check_token(lines[i], "\\begin_inset"): count = count+1 else: count = count-1 + if count == 0: + return i i = i+1 - return i def is_nonempty_line(line): return line != " "*len(line)