From 7edacbcbea138994e9f1befeeed97631f2ddac62 Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Sat, 10 Aug 2002 13:34:57 +0000 Subject: [PATCH] Small changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4929 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 6 ++++++ lib/lyx2lyx/lyxconvert_218.py | 17 +++++++++++++---- lib/lyx2lyx/parser_tools.py | 6 +++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index abe1c12f45..346916d496 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2002-08-10 Dekel Tsur + + * lyx2lyx/parser_tools.py (get_paragraph): Fixed. + + * lyx2lyx/lyxconvert_218.py (convert_ertinset): Remove font commands. + 2002-08-08 Herbert Voss * ui/default.ui: put gather into math menu diff --git a/lib/lyx2lyx/lyxconvert_218.py b/lib/lyx2lyx/lyxconvert_218.py index 996788f995..9a6db44ba7 100644 --- a/lib/lyx2lyx/lyxconvert_218.py +++ b/lib/lyx2lyx/lyxconvert_218.py @@ -190,7 +190,7 @@ def remove_oldert(lines): 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) + j = find_end_of_inset(lines, j) else: break @@ -243,7 +243,7 @@ def remove_oldert(lines): new = new+ert_begin+tmp+["\\end_inset ", ""] if inset: - k3 = find_token(lines, "\\end_inset", k2+1) + k3 = find_end_of_inset(lines, k2) new = new+[""]+lines[k2:k3+1]+[""] # Put an empty line after \end_inset k = k3+1 # Skip the empty line after \end_inset @@ -280,13 +280,22 @@ def convert_ertinset(lines): 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 + i = i+1 def is_ert_paragraph(lines, i): i = find_nonempty_line(lines, i+1) if not check_token(lines[i], "\\begin_inset ERT"): return 0 - j = find_token(lines, "\\end_inset", i) + j = find_end_of_inset(lines, i) k = find_nonempty_line(lines, j+1) return check_token(lines[k], "\\layout") @@ -334,7 +343,7 @@ def remove_figinset(lines): i = find_token(lines, "\\begin_inset Figure", i) if i == -1: break - j = find_token(lines, "\\end_inset", i+1) + j = find_end_of_inset(lines, i) lyxwidth = string.split(lines[i])[3]+"pt" lyxheight = string.split(lines[i])[4]+"pt" diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index d657ba9f56..ac78b93a03 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -74,6 +74,7 @@ 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) @@ -81,15 +82,14 @@ def get_paragraph(lines, i): return i count = 1 while count > 0: - i = find_tokens_backwards(lines, ["\\end_inset", "\\begin_inset"], i) + 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 = i-1 # Finds the matching \end_inset -def skip_inset(lines, i): +def find_end_of_inset(lines, i): count = 1 i = i+1 while count > 0: -- 2.39.2