From 013d66f033052c8cab42e82dbd846649861f6e9a Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Mon, 5 Aug 2002 15:49:20 +0000 Subject: [PATCH] Small changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4863 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyxconvert_218.py | 35 ++++++++++++++++++++++++++++++----- lib/lyx2lyx/parser_tools.py | 1 - 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/lyx2lyx/lyxconvert_218.py b/lib/lyx2lyx/lyxconvert_218.py index 92937b1eee..eddd6c8670 100644 --- a/lib/lyx2lyx/lyxconvert_218.py +++ b/lib/lyx2lyx/lyxconvert_218.py @@ -74,8 +74,7 @@ def remove_oldfloat(lines, language): lines[j2:j2] = ["\\end_deeper "]*(i2-(i+1)) new = floats[floattype]+[""] - new = new+lines[i2:j] - new.append("\\end_inset ") + 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. @@ -84,8 +83,14 @@ def remove_oldfloat(lines, language): # In fact, it might be safer to output '\foo default' for all # font attributes. k = get_paragraph(lines, i) + flag = 0 for token in font_tokens: if find_token(lines, token, k, i) != -1: + if not flag: + # This is not necessary, but we want the output to be + # as similar as posible to the lyx format + flag = 1 + new.append("") if token == "\\lang": new.append(token+" "+language+" ") else: @@ -211,21 +216,41 @@ def remove_oldert(lines): tmp = [] for line in lines[k:k2]: if font_rexp.match(line): + if new2 == []: + # This is not necessary, but we want the output to be + # as similar as posible to the lyx format + new2 = [""] new2.append(line) else: tmp.append(line) if is_empty(tmp): - new = new+tmp + if filter(lambda x:x != "", tmp) != []: + if new == []: + # This is not necessary, but we want the output to be + # as similar as posible to the lyx format + lines[i-1] = lines[i-1]+" " + else: + new = new+[" "] else: new = new+ert_begin+tmp+["\\end_inset ", ""] if inset: k3 = find_token(lines, "\\end_inset", k2+1) - new = new+[""]+lines[k2:k3+1]+["", ""] + new = new+[""]+lines[k2:k3+1]+[""] # Put an empty line after \end_inset k = k3+1 + # Skip the empty line after \end_inset + if not is_nonempty_line(lines[k]): + k = k+1 + new.append("") elif specialchar: - new = new+[specialchar_str] + if new == []: + # This is not necessary, but we want the output to be + # as similar as posible to the lyx format + lines[i-1] = lines[i-1]+specialchar_str + new = [""] + else: + new = new+[specialchar_str, ""] k = k2 else: break diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index 10052a40b9..5acd869497 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -90,7 +90,6 @@ def get_paragraph(lines, i): def is_nonempty_line(line): - line = line[:-1] return line != " "*len(line) def find_nonempty_line(lines, start, end = 0):