On Fri, Nov 16, 2007 at 05:17:41PM +0200, sebastian guttenberg wrote:
> Hi, I just tried to send an example file to demonstrate a bug in the
> index-insets  of 1.6.0svn, but the server rejects the file, because it
> is too big. To whom shall I send the file? The bug is related to index
> of course and also to the import of lyx1.5.2 documents in lyx1.6.0svn.
> To be more precise: I opened a lyx1.5.2-document with lyx1.6.0. A lot of
> index entries were severely corrupted and contained for example only
> dollar signs instead of some math-expression which had been there
> before. 
> - Sebastian

Does the attached patch handle your math-in-index correctly?
If so, this is the way to go.

- Martin

Index: lyx_1_6.py
===================================================================
--- lyx_1_6.py  (revision 21615)
+++ lyx_1_6.py  (working copy)
@@ -359,12 +359,17 @@
             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:
+        re.sub("(\$.*\$)", "\\begin_inset Formula \1\n\\end_inset\n", 
fullcontent)
+        newcontent = fullcontent
+        document.body.insert(i + 3, newcontent)
+        document.body[i + 4] = "\\end_layout"
         i = i + 5
 
 

Reply via email to