]> git.lyx.org Git - features.git/commitdiff
Simplify vspace reversion.
authorRichard Heck <rgheck@comcast.net>
Thu, 4 Nov 2010 12:51:57 +0000 (12:51 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 4 Nov 2010 12:51:57 +0000 (12:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36044 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_2_0.py

index 1b9b89570da830b85ed32670ba9d6627163abab2..63419c8f11797f40ecba063c83568453acf21a72 100644 (file)
@@ -1020,28 +1020,29 @@ def revert_percent_vspace_lengths(document):
           break
       # only revert if a custom length was set and if
       # it used a percent length
-      line = document.body[i]
       r = re.compile(r'\\begin_inset VSpace (.*)$')
-      m = r.match(line)
+      m = r.match(document.body[i])
       length = m.group(1)
-      if length not in ('defskip', 'smallskip', 'medskip', 'bigskip', 'vfill'):
-          # check if the space has a star (protected space)
-          protected = (document.body[i].rfind("*") != -1)
+      if length in ('defskip', 'smallskip', 'medskip', 'bigskip', 'vfill'):
+         i += 1
+         continue
+      # check if the space has a star (protected space)
+      protected = (document.body[i].rfind("*") != -1)
+      if protected:
+          length = length.rstrip('*')
+      # handle percent lengths
+      length = latex_length(length)
+      # latex_length returns "bool,length"
+      percent = length.split(",")[0]
+      length = length.split(",")[1]
+      # revert the VSpace inset to ERT
+      if percent == "True":
           if protected:
-              length = length.rstrip('*')
-          # handle percent lengths
-          length = latex_length(length)
-          # latex_length returns "bool,length"
-          percent = length.split(",")[0]
-          length = length.split(",")[1]
-          # revert the VSpace inset to ERT
-          if percent == "True":
-              if protected:
-                  subst = [old_put_cmd_in_ert("\\vspace*{" + length + "}")]
-              else:
-                  subst = [old_put_cmd_in_ert("\\vspace{" + length + "}")]
-              document.body[i:i + 2] = subst
-      i = i + 1
+              subst = put_cmd_in_ert("\\vspace*{" + length + "}")
+          else:
+              subst = put_cmd_in_ert("\\vspace{" + length + "}")
+          document.body[i:i + 2] = subst
+      i += 1
 
 
 def revert_percent_hspace_lengths(document):