Dov Feldstern wrote:
José Matos wrote:
On Sunday 15 July 2007 19:02:06 Dov Feldstern wrote:
I think I fixed the problem I was having, this patch now works. Please
try applying it and then converting as many files as you have lying
around from older version with it, just to make sure it doesn't break
anything. Jose --- could you also take a look at the code and see if
it's ok?

  Dov. I have thought a long bit about this patch.

It seems to me that are you saying that the translation from step 249 was incomplete.

If that is the case what you are trying to do is to finish that convertion so you don't need a new file format, we just need to add both the convertion and the retroversion to step 249 and there is no more any special case here.

  Am I wrong?


Umm, I was going to say that I think you are wrong, but on second thought, I think you're right. :)

What was bothering me is that there are documents lying around which have already been converted past 249, without the fix. But on second thought, the part that I put into LyX.py is exactly supposed to make sure that such documents *don't* get converted, because maybe they were only created after 249, in which case they aren't supposed to be converted at all! So what you're saying is that we actually don't need a new format, nor do we need the part I wanted to add in LyX.py --- those two things actually cancel each other out... So what we should do, is just add this new function to what happens in the conversion from 249, and everything will be the same... Yes, I believe you're right.

I'll test this and send in a revised patch.

Thanks!
Dov


Attached find a much simplified version of this patch, based on what you suggested. I'm not sure if this is what you meant, but this time I just edited the function used in format change 249 in place, so there's now no need for a new version number, nor any need for changes in LyX.py. I'm still adding a note in FORMAT, though.

OK?

Dov
Index: lyx-devel/development/FORMAT
===================================================================
--- lyx-devel.orig/development/FORMAT   2007-07-18 22:13:08.000000000 +0300
+++ lyx-devel/development/FORMAT        2007-07-18 22:15:48.000000000 +0300
@@ -1,6 +1,11 @@
 LyX file-format changes
 -----------------------
 
+2007-07-19 Dov Feldstern <[EMAIL PROTECTED]>
+
+       * updates to format 249 conversion, so that it now correctly deals with 
+               encodings in footnotes (part of bug 3613)
+
 2007-06-26 Uwe Stֳ¶hr <[EMAIL PROTECTED]> and Dov Feldstern <[EMAIL PROTECTED]>
 
        * format incremented to 276: switching exsting language 'arabic' to 
Index: lyx-devel/lib/lyx2lyx/lyx_1_5.py
===================================================================
--- lyx-devel.orig/lib/lyx2lyx/lyx_1_5.py       2007-07-18 22:13:08.000000000 
+0300
+++ lyx-devel/lib/lyx2lyx/lyx_1_5.py    2007-07-18 22:27:53.000000000 +0300
@@ -246,10 +246,13 @@
 We do this here and not in LyX.py because it is far easier to do the
 necessary parsing in modern formats than in ancient ones.
 """
+    inset_types = ["Foot", "Note"]
     if document.cjk_encoding != '':
         return
     encoding_stack = [document.encoding]
+    inset_stack = []
     lang_re = re.compile(r"^\\lang\s(\S+)")
+    inset_re = re.compile(r"^\\begin_inset\s(\S+)")
     if document.inputencoding == "auto" or document.inputencoding == "default":
         for i in range(len(document.body)):
             result = lang_re.match(document.body[i])
@@ -264,7 +267,11 @@
                     encoding_stack[-1] = lang[language][3]
             elif find_token(document.body, "\\begin_layout", i, i + 1) == i:
                 document.warning("Adding nested encoding %s." % 
encoding_stack[-1], 3)
-                encoding_stack.append(encoding_stack[-1])
+                if len(inset_stack) > 0 and inset_stack[-1] in inset_types:
+                    from lyx2lyx_lang import lang
+                    encoding_stack.append(lang[document.language][3])
+                else:
+                    encoding_stack.append(encoding_stack[-1])
             elif find_token(document.body, "\\end_layout", i, i + 1) == i:
                 document.warning("Removing nested encoding %s." % 
encoding_stack[-1], 3)
                 if len(encoding_stack) == 1:
@@ -272,6 +279,15 @@
                     document.warning("Malformed LyX document: Unexpected 
`\\end_layout'.")
                 else:
                     del encoding_stack[-1]
+            elif find_token(document.body, "\\begin_inset", i, i + 1) == i:
+                inset_result = inset_re.match(document.body[i])
+                if inset_result:
+                    inset_type = inset_result.group(1)
+                    inset_stack.append(inset_type)
+                else: 
+                    inset_stack.append("")
+            elif find_token(document.body, "\\end_inset", i, i + 1) == i:
+                del inset_stack[-1]
             if encoding_stack[-1] != document.encoding:
                 if forward:
                     # This line has been incorrectly interpreted as if it was

Reply via email to