]> git.lyx.org Git - lyx.git/commitdiff
Do a little more work towards making subcaptions work.
authorRichard Heck <rgheck@comcast.net>
Mon, 7 Jul 2008 21:13:02 +0000 (21:13 +0000)
committerRichard Heck <rgheck@comcast.net>
Mon, 7 Jul 2008 21:13:02 +0000 (21:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25497 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_1_6.py

index 3ccf00fc32442cc125e86e8360052763f0dad094..9b8c2764ca72cb3c749269e677b36227927b7f86 100644 (file)
@@ -125,7 +125,7 @@ def read_unicodesymbols():
     # as: \"u.
     r = re.compile(r'\\\\(\W)\{(\w)\}')
     for line in fp.readlines():
-        if line[0] != '#' and line.strip() != "":
+        if line[0] != '#' and line.strip() != "" and line.find("\\") != -1:
             line=line.replace(' "',' ') # remove all quotation marks with spaces before
             line=line.replace('" ',' ') # remove all quotation marks with spaces after
             line=line.replace(r'\"','"') # replace \" by " (for characters with diaeresis)
@@ -173,20 +173,28 @@ def latex2lyx(data):
         #document.warning(str(i) + ":" + document.body[i])
         #document.warning("LAST: " + document.body[-1])
         g = line
-        while mathre.match(g):
-            m = mathre.match(g)
+        m = mathre.match(g)
+        if m == None:
+            g = wrap_into_ert(g, '\\', '\\backslash')
+            g = wrap_into_ert(g, '{', '{')
+            g = wrap_into_ert(g, '}', '}')
+            subst = g.split('\n')
+            retval += subst
+            continue
+        while m != None:
             s = m.group(1)
             f = m.group(2).replace('\\\\', '\\')
             g = m.group(3)
             if s:
-              # this is non-math!
-              s = wrap_into_ert(s, r'\\', '\\backslash')
-              s = wrap_into_ert(s, '{', '{')
-              s = wrap_into_ert(s, '}', '}')
-              subst = s.split('\n')
-              retval += subst
+                # this is non-math!
+                s = wrap_into_ert(s, '\\', '\\backslash')
+                s = wrap_into_ert(s, '{', '{')
+                s = wrap_into_ert(s, '}', '}')
+                subst = s.split('\n')
+                retval += subst
             retval.append("\\begin_inset Formula " + f)
             retval.append("\\end_inset")
+            m = mathre.match(g)
         # Generic, \\ -> \backslash:
         g = wrap_into_ert(g, r'\\', '\\backslash')
         g = wrap_into_ert(g, '{', '{')
@@ -1918,8 +1926,8 @@ def convert_subfig(document):
         addedLines = -2
         subst = ['\\begin_inset Float figure', 'wide false', 'sideways false', 
                  'status open', '', '\\begin_layout Plain Layout', '\\begin_inset Caption', 
-                 '', '\\begin_layout Plain Layout',
-                 caption, '\\end_layout', '', '\\end_inset', '', 
+                 '', '\\begin_layout Plain Layout'] + latex2lyx(caption) + \
+                 [ '\\end_layout', '', '\\end_inset', '', 
                  '\\end_layout', '', '\\begin_layout Plain Layout']
         document.body[i : i] = subst
         addedLines += len(subst)