Pavel Sanda wrote:
José Matos wrote:
Hi,
as I have suggested in the request to test beta 1 it seems that there are
several problems with beta 1. I suggest thus to mini-freeze the development
until Monday where a new beta (2) will be release with these issues fixed.
imho the space-inset fix should go before beta2.
The main part of this is in now. The only remaining issue is the
lyx2lyx. Turns out the problem was that I was only testing conversion
from 334 to 335, which works fine. But conversion from 276 (=1.5.x) was
failing.
Turns out the problem was here:
def convert_spaceinset(document):
" Convert '\\InsetSpace foo' to '\\begin_inset Space foo\n\\end_inset' "
for i in range(len(document.body)):
if re.search(r'\InsetSpace', document.body[i]):
document.body[i] = document.body[i].replace('\\InsetSpace',
'\n\\begin_inset Space')
document.body[i] = document.body[i] + "\n\\end_inset"
which is part of the (older) conversion to 319. I think we may have seen
problems of this sort before. You simply can't do it this way, because
document.body is supposed to be an array of lines, and when you add
newlines to something, it's not an array of lines any more. (I think
it's find_token that then gets confused.) The right way to do it is this:
def convert_spaceinset(document):
" Convert '\\InsetSpace foo' to '\\begin_inset Space foo\n\\end_inset' "
for i in range(len(document.body)):
m = re.match(r'(.*)\InsetSpace (.*)', document.body[i])
if m:
before = m.group(1)
after = m.group(2)
subst = [before, "\\begin_inset Space " + after, "\\end_inset"]
document.body[i: i+1] = subst
There are several other places where this same change needs to be
made---for example, in the (con|re)vert_hfill routines. I don't have
time to do that right now, so I'll leave it to others. It should be
fairly easy. Just search lyx_1_6.py for "replace", and if you see a "\n"
in there, it needs fixing.
I'd suggest we should not release beta 2 until all of this is fixed.
Until the hfill routines are fixed, e.g., you'll see similar failures.
Maybe find_token ought to be able to handle this, but there are probably
other things that would go wrong, then.
I've attached the patch for this bit. I can't commit it, as aussie seems
to be unreachable at the moment. Feel free to commit on my behalf when
that is possible. I may not be back on for a bit.
Richard
Index: lib/lyx2lyx/lyx_1_6.py
===================================================================
--- lib/lyx2lyx/lyx_1_6.py (revision 25016)
+++ lib/lyx2lyx/lyx_1_6.py (working copy)
@@ -1835,9 +1835,12 @@
def convert_spaceinset(document):
" Convert '\\InsetSpace foo' to '\\begin_inset Space foo\n\\end_inset' "
for i in range(len(document.body)):
- if re.search(r'\InsetSpace', document.body[i]):
- document.body[i] = document.body[i].replace('\\InsetSpace', '\n\\begin_inset Space')
- document.body[i] = document.body[i] + "\n\\end_inset"
+ m = re.match(r'(.*)\InsetSpace (.*)', document.body[i])
+ if m:
+ before = m.group(1)
+ after = m.group(2)
+ subst = [before, "\\begin_inset Space " + after, "\\end_inset"]
+ document.body[i: i+1] = subst
def revert_spaceinset(document):