+ if format >= 60 and format <= 62:
+ # nothing to do.
+ i += 1
+ continue
+
+ if format == 59:
+ match = re_InsetLayout_CaptionLTNN.match(lines[i])
+ if not match:
+ i += 1
+ continue
+ # '^(\s*InsetLayout\s+)(Caption:LongTableNonumber)'
+ lead = match.group(1)
+ lines[i] = lead + b"Caption:Unnumbered"
+ i += 1
+ continue
+
+ if format == 58:
+ # nothing to do.
+ i += 1
+ continue
+
+ if format == 57:
+ match = re_IfStyle.match(lines[i])
+ if not match:
+ i += 1
+ continue
+ # b'^(\\s*)IfStyle(\\s+\\S+)
+ lead = match.group(1)
+ trail = match.group(2)
+ lines[i] = lead + b"ModifyStyle" + trail
+ i += 1
+ continue
+
+ if format >= 50 and format <= 56:
+ # nothing to do.
+ i += 1
+ continue
+
+ if format == 49:
+ separator = []
+
+ # delete separator styles
+ match = re_Style.match(lines[i])
+ if match:
+ style = match.group(4).lower()
+ if re_Separator.match(style):
+ del lines[i]
+ while i < len(lines) and not re_End.match(lines[i]):
+ separator.append(lines[i])
+ del lines[i]
+ if i == len(lines):
+ error('Incomplete separator style.')
+ else:
+ del lines[i]
+ continue
+
+ # delete undefinition of separator styles
+ match = re_NoStyle.match(lines[i])
+ if match:
+ style = match.group(4).lower()
+ if re_Separator.match(style):
+ del lines[i]
+ continue
+
+ # replace the CopyStyle statement with the definition of the real
+ # style. This may result in duplicate statements, but that is OK
+ # since the second one will overwrite the first one.
+ match = re_CopyStyle.match(lines[i])
+ if match:
+ style = match.group(4).lower()
+ if re_Separator.match(style):
+ if len(separator) > 0:
+ lines[i:i+1] = separator
+ else:
+ # FIXME: If this style was redefined in an include file,
+ # we should replace the real style and not this default.
+ lines[i:i+1] = [b' Category MainText',
+ b' KeepEmpty 1',
+ b' Margin Dynamic',
+ b' LatexType Paragraph',
+ b' LatexName dummy',
+ b' ParIndent MM',
+ b' Align Block',
+ b' LabelType Static',
+ b' LabelString "--- Separate Environment ---"',
+ b' LabelFont',
+ b' Family Roman',
+ b' Series Medium',
+ b' Size Normal',
+ b' Color Blue',
+ b' EndFont',
+ b' HTMLLabel NONE']
+ i += 1
+ continue
+
+ if format == 48:
+ # The default of ResetsFont in LyX changed from true to false,
+ # because it is now used for all InsetLayouts, not only flex ones.
+ # Therefore we need to set it to true for all flex insets which do
+ # do not already have a ResetsFont.
+ match = re_InsetLayout2.match(lines[i])
+ if not match:
+ i += 1
+ continue
+
+ name = match.group(1).lower()
+ if name != b"flex" and name != b"\"flex\"" and name[0:5] != b"flex:" and name [0:6] != b"\"flex:":
+ i += 1
+ continue
+
+ resetsfont_found = False
+ inherited = False
+ notdone = True
+ while i < len(lines):
+ match = re_ResetsFont.match(lines[i])
+ if match:
+ resetsfont_found = True
+ else:
+ match = re_CopyStyle.match(lines[i])
+ if match:
+ inherited = True
+ else:
+ match = re_End.match(lines[i])
+ if match:
+ break
+ i += 1
+ if not resetsfont_found and not inherited:
+ lines.insert(i, b"\tResetsFont true")
+
+ continue
+
+ if format >= 44 and format <= 47:
+ # nothing to do.
+ i += 1
+ continue
+
+ if format == 43:
+ match = re_LabelTypeIsCounter.match(lines[i])
+ if match:
+ if inchapter:
+ lines[i] = match.group(1) + b"LabelType" + match.group(2) + b"Above"
+ else:
+ lines[i] = match.group(1) + b"LabelType" + match.group(2) + b"Static"
+
+ match = re_TopEnvironment.match(lines[i])
+ if match:
+ lines[i] = match.group(1) + b"LabelType" + match.group(2) + b"Above"
+
+ match = re_CenteredEnvironment.match(lines[i])
+ if match:
+ lines[i] = match.group(1) + b"LabelType" + match.group(2) + b"Centered"
+
+ if inchapter:
+ match = re_Style.match(lines[i])
+ if match:
+ inchapter = False
+ else:
+ match = re_ChapterStyle.match(lines[i])
+ if match:
+ inchapter = True
+
+ i += 1
+ continue
+
+ if format == 42:
+ if lines[i] == b"InsetLayout Caption":
+ lines[i] = b"InsetLayout Caption:Standard"
+ i += 1
+ continue
+
+ if format == 41:
+ # nothing to do.
+ i += 1
+ continue
+
+ if format == 40:
+ # reset counters on Style beginning
+ match = re_Style.match(lines[i])
+ if match:
+ opts = 0
+ reqs = 0
+ i += 1
+ continue
+ match = re_OptArgs.match(lines[i])
+ if match:
+ # Save number of optional arguments
+ space1 = match.group(1)
+ opts = int(match.group(3))
+ # OptionalArgs 0 > ResetArgs 1
+ if opts == 0:
+ lines[i] = space1 + b"ResetArgs\t1"
+ i += 1
+ else:
+ del lines[i]
+ continue
+ match = re_ReqArgs.match(lines[i])
+ if match:
+ # Save number of required arguments
+ space1 = match.group(1)
+ reqs = int(match.group(3))
+ del lines[i]
+ continue
+ # Insert the required number of arguments at the end of the style definition
+ match = re_End.match(lines[i])
+ if match:
+ newarg = ['']
+ # First the optionals (this is the required order pre 2.1)
+ if opts > 0:
+ if opts == 1:
+ newarg = [ b'%sArgument 1' % (space1),
+ b'%s\tLabelString\t\"Optional Layout Argument\"' % (space1),
+ b'%sEndArgument' % (space1)]
+ elif opts > 1:
+ actopt = 1
+ while actopt < (opts + 1):
+ newarg += [ b'%sArgument %d' % (space1, actopt),
+ b'%s\tLabelString\t\"Optional Layout Argument %d\"' % (space1, actopt),
+ b'%sEndArgument' % (space1)]
+ actopt += 1
+ # Now the mandatories
+ if reqs > 0:
+ actopt = opts + 1
+ while actopt < (opts + reqs + 1):
+ newarg += [ b'%sArgument %d' % (space1, actopt),
+ b'%s\tLabelString\t"Required Layout Argument %d"' % (space1, actopt - opts),
+ b'%s\tMandatory\t1' % (space1),
+ b'%sEndArgument' % (space1)]
+ actopt += 1
+ # Since we replace the "End" line, re-add this line
+ if len(newarg) > 1:
+ newarg += [b'End']
+ lines[i:i+1] = newarg
+ i += len(newarg)
+ # Reset the counters
+ opts = 0
+ reqs = 0
+ i += 1
+ continue
+