+ if format == 34:
+ match = re_InsetLayout2.match(lines[i])
+ if not match:
+ match = re_QInsetLayout2.match(lines[i])
+ if not match:
+ match = re_CopyStyle2.match(lines[i])
+ if not match:
+ i += 1
+ continue
+ style = match.group(2)
+
+ if flexstyles.count(style):
+ lines[i] = match.group(1) + "\"Flex:" + style + "\""
+ i += 1
+ continue
+
+ name = match.group(1)
+ names = name.split(":", 1)
+ if len(names) > 1 and names[0] == "Flex":
+ i += 1
+ continue
+
+ isflex = False
+ for j in range(i + 1, len(lines)):
+ if re_IsFlex.match(lines[j]):
+ isflex = True
+ break
+ if re_End.match(lines[j]):
+ break
+
+ if isflex:
+ flexstyles.append(name)
+ lines[i] = "InsetLayout \"Flex:" + name + "\""
+
+ i += 1
+ continue
+
+ if format == 33:
+ m = re_Fill.match(lines[i])
+ if m:
+ lines[i] = ""
+ i += 1
+ continue
+
+ if format == 32:
+ match = re_NeedsFloatPkg.match(lines[i])
+ if match:
+ space = match.group(1)
+ val = match.group(2)
+ lines[i] = space + "UsesFloatPkg " + val
+ newval = 'true'
+ if val == '1' or val.lower() == 'true':
+ newval = 'false'
+ lines.insert(i, space + "IsPredefined " + newval)
+ i += 1
+ i += 1
+ continue
+
+ # Only new features
+ if format >= 29 and format <= 31:
+ i += 1
+ continue
+
+ if format == 28:
+ match = re_InsetLayout.match(lines[i])
+ if match:
+ lines[i] = "InsetLayout Flex:" + match.group(1)
+ else:
+ match = re_QInsetLayout.match(lines[i])
+ if match:
+ lines[i] = "InsetLayout \"Flex:" + match.group(1) + "\""
+ else:
+ match = re_InsetLayout_CopyStyle.match(lines[i])
+ if match:
+ lines[i] = "\tCopyStyle Flex:" + match.group(1)
+ else:
+ match = re_QInsetLayout_CopyStyle.match(lines[i])
+ if match:
+ lines[i] = "\tCopyStyle \"Flex:" + match.group(1) + "\""
+ i += 1
+ continue
+
+ # Only new features
+ if format >= 24 and format <= 27:
+ i += 1
+ continue
+
+ if format == 23:
+ match = re_Float.match(lines[i])
+ i += 1
+ if not match:
+ continue
+ # we need to do two things:
+ # (i) Convert Builtin to NeedsFloatPkg
+ # (ii) Write ListCommand lines for the builtin floats table and figure
+ builtin = False
+ cmd = ""
+ while True and i < len(lines):
+ m1 = re_End.match(lines[i])
+ if m1:
+ if builtin and cmd:
+ line = " ListCommand " + cmd
+ lines.insert(i, line)
+ i += 1
+ break
+ m2 = re_Builtin.match(lines[i])
+ if m2:
+ builtin = True
+ ws1 = m2.group(1)
+ arg = m2.group(2)
+ newarg = ""
+ if re_True.match(arg):
+ newarg = "false"
+ else:
+ newarg = "true"
+ lines[i] = ws1 + "NeedsFloatPkg " + newarg
+ m3 = re_Type.match(lines[i])
+ if m3:
+ fltype = m3.group(1)
+ fltype = fltype.lower()
+ if fltype == "table":
+ cmd = "listoftables"
+ elif fltype == "figure":
+ cmd = "listoffigures"
+ # else unknown, which is why we're doing this
+ i += 1
+ continue
+