Jürgen Spitzmüller wrote:
rgheck wrote:
One of our users has had a problem converting certain documents into
1.6. Turns out these are documents that have subfigures but NO
subcaption. Right now, lyx2lyx throws an error in this case. It's easy
to fix this, but what should we do? Can we just omit the caption? Should
we write and empty caption inset?

I guess we can ommit the caption. The caption is optional in the subfig command.

I've got a working patch where lyx2lyx writes an empty caption inset. Patch is attached. We could omit the caption inset altogether if we wanted, but will LyX accept that?

rh

Index: lib/lyx2lyx/lyx_1_6.py
===================================================================
--- lib/lyx2lyx/lyx_1_6.py	(revision 27080)
+++ lib/lyx2lyx/lyx_1_6.py	(working copy)
@@ -253,7 +253,7 @@
     lines, suitable for insertion into document.body.'''
 
     if not data:
-        return []
+        return [""]
     retval = []
 
     # Convert LaTeX to Unicode
@@ -2119,6 +2119,7 @@
     " Convert subfigures to subfloats. "
     i = 0
     while 1:
+        addedLines = 0
         i = find_token(document.body, '\\begin_inset Graphics', i)
         if i == -1:
             return
@@ -2133,13 +2134,13 @@
             continue
         l = find_token(document.body, '\tsubcaptionText', i, endInset)
         if l == -1:
-            document.warning("Malformed lyx document: Can't find subcaptionText!")
-            i = endInset
-            continue
-        caption = document.body[l][16:].strip('"')
-        del document.body[l]
+            caption = ""
+        else: 
+            caption = document.body[l][16:].strip('"')
+            del document.body[l]
+            addedLines -= 1
         del document.body[k]
-        addedLines = -2
+        addedLines -= 1
         subst = ['\\begin_inset Float figure', 'wide false', 'sideways false',
                  'status open', '', '\\begin_layout Plain Layout', '\\begin_inset Caption',
                  '', '\\begin_layout Plain Layout'] + latex2lyx(caption) + \

Reply via email to