]> git.lyx.org Git - lyx.git/commitdiff
Correct conversion of math insets inside Index
authorMartin Vermeer <martin.vermeer@hut.fi>
Mon, 19 Nov 2007 19:53:54 +0000 (19:53 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Mon, 19 Nov 2007 19:53:54 +0000 (19:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21680 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_1_6.py

index d62ef3eb4df9e40760e553692d397fb80186a5e2..ce4d31d104978a834b2ebfe34107ef1752837850 100644 (file)
@@ -359,12 +359,28 @@ def convert_latexcommand_index(document):
             return
         if document.body[i + 1] != "LatexCommand index": # Might also be index_print
             return
-        fullcommand = document.body[i + 2]
-        document.body[i] = "\\begin_inset Index"
-        document.body[i + 1] = "status collapsed"
-        document.body[i + 2] = "\\begin_layout standard"
-        document.body.insert(i + 3, fullcommand[6:].strip('"'))
-        document.body.insert(i + 4, "\\end_layout")
+        fullcontent = document.body[i + 2][6:].strip('"')
+        document.body[i:i + 2] = ["\\begin_inset Index",
+          "status collapsed",
+          "\\begin_layout standard"]
+        # Put here the conversions needed from LaTeX string
+        # to LyXText:
+        # Math:
+        r = re.compile('^(.*?)(\$.*?\$)(.*)')
+        g = fullcontent
+        while r.match(g):
+          m = r.match(g)
+          s = m.group(1)
+          f = m.group(2).replace('\\\\', '\\')
+          g = m.group(3)
+          if s:
+            document.body.insert(i + 3, s)
+            i += 1
+          document.body.insert(i + 3, "\\begin_inset Formula " + f)
+          document.body.insert(i + 4, "\\end_inset")
+          i += 2
+        document.body.insert(i + 3, g)
+        document.body[i + 4] = "\\end_layout"
         i = i + 5