]> git.lyx.org Git - features.git/commitdiff
lyx_2_0.py: fix glue length reversion routine again
authorUwe Stöhr <uwestoehr@web.de>
Tue, 21 Jul 2009 15:51:36 +0000 (15:51 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Tue, 21 Jul 2009 15:51:36 +0000 (15:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30733 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_2_0.py

index 5a946be30393f26bc424928c39cf1ce059f77ced..e88136c6f823ba5401d91a34e7641772c5034441 100644 (file)
@@ -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: