From 21c5e4633d3858cb6b212fc335b89ab0d2f43245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 21 Jul 2009 17:19:33 +0000 Subject: [PATCH] * lyx_2_0.py (revert_percent_hspace_lengths, revert_hspace_glue_lengths): - fix bug where a \hspace*{} was not reverted if it was followed by a \hspace{}. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30737 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_2_0.py | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index a9b09ec75f..a4094f9785 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -1017,18 +1017,11 @@ def revert_percent_vspace_lengths(document): def revert_percent_hspace_lengths(document): " Revert relative HSpace lengths to ERT " i = 0 - j = 0 while True: - i = find_token(document.body, "\\begin_inset space \\hspace{}", i) + i = find_token(document.body, "\\begin_inset space \\hspace", i) if i == -1: - j = find_token(document.body, "\\begin_inset space \\hspace*{}", j) - if j == -1: - break - else: - star = True - i = j - else: - star = False + break + star = (document.body[i].find("\\hspace*{}") != -1) # only revert when a custom length was set and when # it used a percent length length = get_value(document.body, '\\length', i+1) @@ -1049,24 +1042,16 @@ def revert_percent_hspace_lengths(document): subst = [put_cmd_in_ert("\\hspace{" + length + "}")] document.body[i:i+3] = subst i = i + 2 - j = i def revert_hspace_glue_lengths(document): " Revert HSpace glue lengths to ERT " i = 0 - j = 0 while True: - i = find_token(document.body, "\\begin_inset space \\hspace{}", i) + i = find_token(document.body, "\\begin_inset space \\hspace", i) if i == -1: - j = find_token(document.body, "\\begin_inset space \\hspace*{}", j) - if j == -1: - break - else: - star = True - i = j - else: - star = False + break + star = (document.body[i].find("\\hspace*{}") != -1) length = get_value(document.body, '\\length', i+1) if length == '': document.warning("Malformed lyx document: Missing '\\length' in Space inset.") @@ -1085,14 +1070,13 @@ def revert_hspace_glue_lengths(document): # revert the HSpace inset to ERT # allow leading - n = length.find("-") - if n <> 0 or (n == 0 and (length.rfind("plus") > -1 or length.rfind("minus") > -1)): + if n != 0 or (n == 0 and (length.rfind("plus") > -1 or length.rfind("minus") > -1)): if star == True: subst = [put_cmd_in_ert("\\hspace*{" + length + "}")] else: subst = [put_cmd_in_ert("\\hspace{" + length + "}")] document.body[i:i+3] = subst i = i + 2 - j = i ##