]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_1_4.py
Don't use widest label for numerical citations.
[lyx.git] / lib / lyx2lyx / lyx_1_4.py
index 9952d14a8f05c4adb3c4aa94b0e5d180fbbc34b2..9fb583f0711a71f039b385e1bcec17bf461037a2 100644 (file)
@@ -16,7 +16,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 """ Convert files to the file format generated by lyx 1.4"""
 
@@ -24,7 +24,7 @@ import re
 from os import access, F_OK
 import os.path
 from parser_tools import check_token, find_token, \
-                         get_value, del_token, is_nonempty_line, \
+                         get_value, is_nonempty_line, \
                          find_tokens, find_end_of, find_beginning_of, find_token_exact, find_tokens_exact, \
                          find_re, find_tokens_backwards
 from sys import stdin
@@ -84,6 +84,21 @@ def find_end_of_inset(lines, i):
     "Finds the matching \end_inset"
     return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
 
+def del_token(lines, token, start, end):
+    """ del_token(lines, token, start, end) -> int
+
+    Find the lower line in lines where token is the first element and
+    delete that line.
+
+    Returns the number of lines remaining."""
+
+    k = find_token_exact(lines, token, start, end)
+    if k == -1:
+        return end
+    else:
+        del lines[k]
+        return end - 1
+
 # End of helper functions
 ####################################################################
 
@@ -1832,7 +1847,13 @@ def revert_float(document):
         i = find_token_exact(document.body, '\\begin_inset Float', i)
         if i == -1:
             return
-        floatline = document.body[i]
+        line = document.body[i]
+        r = re.compile(r'\\begin_inset Float (.*)$')
+        m = r.match(line)
+        floattype = m.group(1)
+        if floattype != "figure" and floattype != "table":
+            i = i + 1
+            continue
         j = find_end_of_inset(document.body, i)
         if j == -1:
             document.warning("Malformed lyx document: Missing '\\end_inset'.")
@@ -1843,9 +1864,6 @@ def revert_float(document):
             if l == -1:
                 document.warning("Malformed LyX document: Missing `\\begin_layout Standard' in Float inset.")
                 return
-            floattype = "table"
-            if floatline == "\\begin_inset Float figure":
-                floattype = "figure"
             document.body[j] = '\\layout Standard\n\\begin_inset ERT\nstatus Collapsed\n\n' \
             '\\layout Standard\n\n\n\\backslash\n' \
             'end{sideways' + floattype + '}\n\n\\end_inset\n'