From e09862ec152f4ac43cc3d21e63726a0c5ce0539b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Tue, 21 Jul 2009 15:51:36 +0000 Subject: [PATCH] lyx_2_0.py: fix glue length reversion routine again git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30733 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_2_0.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index 5a946be303..e88136c6f8 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -309,11 +309,23 @@ def latex_length(string): value = str(float(value)/100) begin = string[:minus+1] string = begin + value + "\\paperheight" + # replace + and -, but only when the - is not the first character + string = string.replace("+", " plus ") + if string.find("-") == 0: + minusstring = string[1:] + minusstring = minusstring.replace("-", " minus ") + string = "-" + minusstring + else: + string = string.replace("-", " minus ") + # handle the case that "+-1mm" was used because LaTeX only understands + # "plus 1mm minus 1mm" + if string.find("plus minus"): + lastvaluepos = string.rfind(" ") + lastvalue = string[lastvaluepos:] + string = string.replace(" ", lastvalue + " ") if percent == False: return "False," + string else: - string = string.replace("+", " plus ") - string = string.replace("-", " minus ") return "True," + string @@ -1078,7 +1090,8 @@ def revert_hspace_glue_lengths(document): length = length[m+1:] # revert the HSpace inset to ERT # allow leading - - if length.rfind("-") <> 0 or (length.rfind("-") == 0 and length.rfind("+") > -1): + n = length.find("-") + 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: -- 2.39.2