From: Richard Heck Date: Mon, 29 Mar 2010 16:29:57 +0000 (+0000) Subject: Fix a minor bug in the xymatrix lyx2lyx stuff and make it a bit more X-Git-Tag: 2.0.0~3666 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7ba836548ff380070ac0f0e00647b192fafd6ad3;p=lyx.git Fix a minor bug in the xymatrix lyx2lyx stuff and make it a bit more pythonic. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33913 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index d3f310fefa..b5ab97e447 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -1268,7 +1268,8 @@ def revert_equalspacing_xymatrix(document): " Revert a Formula with xymatrix@! to an ERT inset " i = 0 j = 0 - has_preamble = 0 + has_preamble = False + has_equal_spacing = False while True: found = -1 i = find_token(document.body, "\\begin_inset Formula", i) @@ -1279,24 +1280,26 @@ def revert_equalspacing_xymatrix(document): document.warning("Malformed LyX document: Could not find end of Formula inset.") break - for curline in range(len(document.body[i:j])): - found = document.body[i+curline].find("\\xymatrix@!") + for curline in range(i,j): + found = document.body[curline].find("\\xymatrix@!") if found != -1: break if found != -1: + has_equal_spacing = True content = document.body[i][21:] - for curline in range(len(document.body[i+1:j])): - content += document.body[i+1+curline] + content += '\n'.join(document.body[i+1:j]) subst = [put_cmd_in_ert(content)] document.body[i:j+1] = subst + i += 1 else: - for curline in range(len(document.body[i:j])): - l = document.body[i+curline].find("\\xymatrix") + for curline in range(i,j): + l = document.body[curline].find("\\xymatrix") if l != -1: - has_preamble = 1; - i += 1 - if has_preamble == 0: + has_preamble = True; + break; + i = j + 1 + if has_equal_spacing and not has_preamble: add_to_preamble(document, ['\\usepackage[all]{xy}']) ##