- if (line.startswith("\\begin_inset ") and
- line[13:].split()[0] in ["CommandInset", "ERT", "External",
- "Formula", "FormulaMacro", "Graphics", "IPA", "listings"]
- or line == "\\begin_inset Flex Code"):
- j = find_end_of_inset(document.body, i)
- if j == -1:
- document.warning("Malformed LyX document: Can't find end of "
- + words[1] + " inset at line " + str(i))
- new_body.append(line)
+ # do not touch hyphens in some insets (cf. lyx_2_2.convert_dashes):
+ try:
+ inset_type, start, end = get_containing_inset(document.body, i)
+ except TypeError: # no containing inset
+ inset_type, start, end = "no inset", -1, -1
+ if (inset_type.split()[0] in
+ ["CommandInset", "ERT", "External", "Formula",
+ "FormulaMacro", "Graphics", "IPA", "listings"]
+ or inset_type == "Flex Code"):
+ i = end