The problem here is that
for i in range(len(document.body)):
sets the range BEFORE we do any of our manipulations. But those manipulations
can make document.body longer. As a result, we can fail to test some lines.
Instead, use:
while i < len(document.body):
and increment i in the while loop.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25050
a592a061-630c-0410-9148-
cb99ea01b6c8
def convert_spaceinset(document):
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
+ " Convert '\\InsetSpace foo' to '\\begin_inset Space foo\n\\end_inset' "
+ i = 0
+ while i < 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
+ i = i + 3
+ else:
+ i = i + 1
def revert_spaceinset(document):
def revert_spaceinset(document):