diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index d7dc87a0d5..6e2e310338 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -1022,7 +1022,7 @@ def revert_percent_hspace_lengths(document): if i == -1: break star = (document.body[i].find("\\hspace*{}") != -1) - # only revert if a custom length was set and when + # only revert if a custom length was set and if # it used a percent length length = get_value(document.body, '\\length', i+1) if length == '': @@ -1057,18 +1057,17 @@ def revert_hspace_glue_lengths(document): return # only revert if the length contains a plus or minus at pos != 0 glue = re.compile(r'.+[\+-]') - if glue.search(length) == None: - break - # handle percent lengths - length = latex_length(length) - # latex_length returns "bool,length" - length = length.split(",")[1] - # revert the HSpace inset to ERT - if star == True: - subst = [put_cmd_in_ert("\\hspace*{" + length + "}")] - else: - subst = [put_cmd_in_ert("\\hspace{" + length + "}")] - document.body[i:i+3] = subst + if glue.search(length): + # handle percent lengths + length = latex_length(length) + # latex_length returns "bool,length" + length = length.split(",")[1] + # revert the HSpace inset to ERT + 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