El 17.04.2017 a las 17:22, Richard Heck escribió:

OK.

It is in.

Attached is another fix fixing the box reversion from 2.0 to 1.6. Kornel verified that it works for him too OK to go in?

You can use git blame to identify where the changes come from. Then we
can look at the individual commits and see if they should be backported.

I would but my spare time for LyX is almost over. Nevertheless I collected the obvious fixes and whitespace issues. Attached are the patches. The whitespace is not important but there are several issues fixed that I made quite often: "\" instead of "\\". This makes no problems on Windows but on the other OSes.

OK to go in as well?

thanks and regards
Uwe
diff --git 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_2_0-113c9a2.000.py" 
"b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_2_0.py"
index 1f10154440..1bbe34ad20 100644
--- 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_2_0-113c9a2.000.py"
+++ "b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_2_0.py"
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 # This file is part of lyx2lyx
-# -*- coding: utf-8 -*-
 # Copyright (C) 2011 The LyX team
 #
 # This program is free software; you can redistribute it and/or
@@ -27,7 +26,7 @@ from parser_tools import find_token, find_end_of, 
find_tokens, \
   find_token_exact, find_end_of_inset, find_end_of_layout, \
   find_token_backwards, is_in_inset, get_value, get_quoted_value, \
   del_token, check_token, get_option_value
-  
+
 from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
   put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
   revert_font_attrs, hex2ratio, str2bool
@@ -156,7 +155,7 @@ def revert_phantom_types(document, ptype, cmd):
           i = end
           continue
       substi = ["\\begin_inset ERT", "status collapsed", "",
-                "\\begin_layout Plain Layout", "", "", "\\backslash", 
+                "\\begin_layout Plain Layout", "", "", "\\backslash",
                 cmd + "{", "\\end_layout", "", "\\end_inset"]
       substj = ["\\size default", "", "\\begin_inset ERT", "status collapsed", 
"",
                 "\\begin_layout Plain Layout", "", "}", "\\end_layout", "", 
"\\end_inset"]
@@ -168,7 +167,7 @@ def revert_phantom_types(document, ptype, cmd):
 
 def revert_phantom(document):
     revert_phantom_types(document, "Phantom", "phantom")
-    
+
 def revert_hphantom(document):
     revert_phantom_types(document, "HPhantom", "hphantom")
 
@@ -200,7 +199,7 @@ def revert_xetex(document):
     roman = sans = typew = "default"
     osf = False
     sf_scale = tt_scale = 100.0
-    
+
     i = find_token(document.header, "\\font_roman", 0)
     if i == -1:
         document.warning("Malformed LyX document: Missing \\font_roman.")
@@ -214,7 +213,7 @@ def revert_xetex(document):
     else:
         sans = get_value(document.header, "\\font_sans", i)
         document.header[i] = "\\font_sans default"
-    
+
     i = find_token(document.header, "\\font_typewriter", 0)
     if i == -1:
         document.warning("Malformed LyX document: Missing \\font_typewriter.")
@@ -235,7 +234,7 @@ def revert_xetex(document):
     else:
         # we do not need this value.
         document.header[i] = "\\font_sc false"
-    
+
     i = find_token(document.header, "\\font_sf_scale", 0)
     if i == -1:
         document.warning("Malformed LyX document: Missing \\font_sf_scale.")
@@ -279,14 +278,14 @@ def revert_xetex(document):
         pretext.append(tw)
     if osf:
         pretext.append('\\defaultfontfeatures{Numbers=OldStyle}')
-    pretext.append('\usepackage{xunicode}')
-    pretext.append('\usepackage{xltxtra}')
+    pretext.append('\\usepackage{xunicode}')
+    pretext.append('\\usepackage{xltxtra}')
     insert_to_preamble(document, pretext)
 
 
 def revert_outputformat(document):
     " Remove default output format param "
-    
+
     if not del_token(document.header, '\\default_output_format', 0):
         document.warning("Malformed LyX document: Missing 
\\default_output_format.")
 
@@ -344,7 +343,7 @@ def revert_splitindex(document):
     preamble = []
     if useindices:
          preamble.append("\\usepackage{splitidx})")
-    
+
     # deal with index declarations in the preamble
     i = 0
     while True:
@@ -355,7 +354,7 @@ def revert_splitindex(document):
         if k == -1:
             document.warning("Malformed LyX document: Missing \\end_index.")
             return
-        if useindices:    
+        if useindices:
           line = document.header[i]
           l = re.compile(r'\\index (.*)$')
           m = l.match(line)
@@ -366,7 +365,7 @@ def revert_splitindex(document):
         del document.header[i:k + 1]
     if preamble:
         insert_to_preamble(document, preamble)
-        
+
     # deal with index insets
     # these need to have the argument removed
     i = 0
@@ -392,7 +391,7 @@ def revert_splitindex(document):
             subst = put_cmd_in_ert("\\sindex[" + itype + "]{" + content + "}")
             document.body[i:k + 1] = subst
         i = i + 1
-        
+
     # deal with index_print insets
     i = 0
     while True:
@@ -431,7 +430,7 @@ def convert_splitindex(document):
         if document.body[i + 1].find('LatexCommand printindex') == -1:
             document.warning("Malformed LyX document: Incomplete printindex 
inset.")
             return
-        subst = ["LatexCommand printindex", 
+        subst = ["LatexCommand printindex",
             "type \"idx\""]
         document.body[i + 1:i + 2] = subst
         i = i + 1
@@ -515,10 +514,10 @@ def revert_ulinelatex(document):
 
 def revert_custom_processors(document):
     " Remove bibtex_command and index_command params "
-    
+
     if not del_token(document.header, '\\bibtex_command', 0):
         document.warning("Malformed LyX document: Missing \\bibtex_command.")
-    
+
     if not del_token(document.header, '\\index_command', 0):
         document.warning("Malformed LyX document: Missing \\index_command.")
 
@@ -596,10 +595,10 @@ def revert_longtable_align(document):
       if j == -1:
           i += 1
           continue
-      # FIXME Is this correct? It wipes out everything after the 
+      # FIXME Is this correct? It wipes out everything after the
       # one we found.
       document.body[fline] = document.body[fline][:j - 1] + '>'
-      # since there could be a tabular inside this one, we 
+      # since there could be a tabular inside this one, we
       # cannot jump to end.
       i += 1
 
@@ -743,7 +742,7 @@ def convert_author_id(document):
     i = 0
     anum = 1
     re_author = re.compile(r'(\\author) (\".*\")\s*(.*)$')
-    
+
     while True:
         i = find_token(document.header, "\\author", i)
         if i == -1:
@@ -755,7 +754,7 @@ def convert_author_id(document):
             document.header[i] = "\\author %i %s %s" % (anum, name, email)
         anum += 1
         i += 1
-        
+
     i = 0
     while True:
         i = find_token(document.body, "\\change_", i)
@@ -859,7 +858,7 @@ def revert_mhchem(document):
 
     if mhchem == "off":
       # don't load case
-      return 
+      return
 
     if mhchem == "auto":
         i = 0
@@ -874,9 +873,9 @@ def revert_mhchem(document):
             i += 1
 
     if mhchem == "on":
-        pre = ["\\PassOptionsToPackage{version=3}{mhchem}", 
+        pre = ["\\PassOptionsToPackage{version=3}{mhchem}",
           "\\usepackage{mhchem}"]
-        insert_to_preamble(document, pre) 
+        insert_to_preamble(document, pre)
 
 
 def revert_fontenc(document):
@@ -916,7 +915,7 @@ def merge_gbrief(document):
                     "Verteiler":       "cc",
                     "Gruss":           "Closing"}
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_layout", i)
         if i == -1:
             break
@@ -926,7 +925,7 @@ def merge_gbrief(document):
             document.body[i] = "\\begin_layout " + obsoletedby[layout]
 
         i += 1
-        
+
     document.textclass = "g-brief"
     document.set_textclass()
 
@@ -989,7 +988,7 @@ def revert_multirow(document):
         if i == -1:
             begin_table = end_table
             continue
-        
+
         # store the number of rows and columns
         numrows = get_option_value(document.body[begin_table], "rows")
         numcols = get_option_value(document.body[begin_table], "columns")
@@ -1016,13 +1015,13 @@ def revert_multirow(document):
               break
             begin_cell = begin_row
             multirows.append([])
-            for column in range(numcols):            
+            for column in range(numcols):
                 begin_cell = find_token(document.body, '<cell ', begin_cell, 
end_row)
                 if begin_cell == -1:
                   document.warning("Can't find column " + str(column + 1) + \
                     "in row " + str(row + 1))
                   break
-                # NOTE 
+                # NOTE
                 # this will fail if someone puts "</cell>" in a cell, but
                 # that seems fairly unlikely.
                 end_cell = find_end_of(document.body, begin_cell, '<cell', 
'</cell>')
@@ -1122,7 +1121,7 @@ def revert_math_output(document):
     else:
         document.warning("Unable to match " + document.header[i])
     document.header[i] = "\\html_use_mathml " + newval
-                
+
 
 
 def revert_inset_preview(document):
@@ -1137,7 +1136,7 @@ def revert_inset_preview(document):
           document.warning("Malformed LyX document: Could not find end of 
Preview inset.")
           i += 1
           continue
-      
+
       # This has several issues.
       # We need to do something about the layouts inside InsetPreview.
       # If we just leave the first one, then we have something like:
@@ -1146,16 +1145,16 @@ def revert_inset_preview(document):
       # \begin_layout Standard
       # and we get a "no \end_layout" error. So something has to be done.
       # Ideally, we would check if it is the same as the layout we are in.
-      # If so, we just remove it; if not, we end the active one. But it is 
+      # If so, we just remove it; if not, we end the active one. But it is
       # not easy to know what layout we are in, due to depth changes, etc,
       # and it is not clear to me how much work it is worth doing. In most
       # cases, the layout will probably be the same.
-      # 
+      #
       # For the same reason, we have to remove the \end_layout tag at the
       # end of the last layout in the inset. Again, that will sometimes be
       # wrong, but it will usually be right. To know what to do, we would
       # again have to know what layout the inset is in.
-      
+
       blay = find_token(document.body, "\\begin_layout", i, iend)
       if blay == -1:
           document.warning("Can't find layout for preview inset!")
@@ -1167,13 +1166,13 @@ def revert_inset_preview(document):
 
       # This is where we would check what layout we are in.
       # The check for Standard is definitely wrong.
-      # 
+      #
       # lay = document.body[blay].split(None, 1)[1]
       # if lay != oldlayout:
       #     # record a boolean to tell us what to do later....
       #     # better to do it later, since (a) it won't mess up
       #     # the numbering and (b) we only modify at the end.
-        
+
       # we want to delete the last \\end_layout in this inset, too.
       # note that this may not be the \\end_layout that goes with blay!!
       bend = find_end_of_layout(document.body, blay)
@@ -1193,7 +1192,7 @@ def revert_inset_preview(document):
       del document.body[bend]
       del document.body[i:blay + 1]
       # we do not need to reset i
-                
+
 
 def revert_equalspacing_xymatrix(document):
     " Revert a Formula with xymatrix@! to an ERT inset "
@@ -1210,12 +1209,12 @@ def revert_equalspacing_xymatrix(document):
           document.warning("Malformed LyX document: Could not find end of 
Formula inset.")
           i += 1
           continue
-      
+
       for curline in range(i,j):
           found = document.body[curline].find("\\xymatrix@!")
           if found != -1:
               break
- 
+
       if found != -1:
           has_equal_spacing = True
           content = [document.body[i][21:]]
@@ -1230,7 +1229,7 @@ def revert_equalspacing_xymatrix(document):
                   has_preamble = True;
                   break;
           i = j + 1
-  
+
     if has_equal_spacing and not has_preamble:
         add_to_preamble(document, ['\\usepackage[all]{xy}'])
 
@@ -1247,7 +1246,7 @@ def revert_notefontcolor(document):
 
     # are there any grey notes?
     if find_token(document.body, "\\begin_inset Note Greyedout", 0) == -1:
-        # no need to do anything else, and \renewcommand will throw 
+        # no need to do anything else, and \renewcommand will throw
         # an error since lyxgreyedout will not exist.
         return
 
@@ -1265,21 +1264,21 @@ def revert_notefontcolor(document):
 
 
 def revert_turkmen(document):
-    "Set language Turkmen to English" 
+    "Set language Turkmen to English"
 
-    if document.language == "turkmen": 
-        document.language = "english" 
-        i = find_token(document.header, "\\language", 0) 
-        if i != -1: 
-            document.header[i] = "\\language english" 
+    if document.language == "turkmen":
+        document.language = "english"
+        i = find_token(document.header, "\\language", 0)
+        if i != -1:
+            document.header[i] = "\\language english"
 
-    j = 0 
-    while True: 
-        j = find_token(document.body, "\\lang turkmen", j) 
-        if j == -1: 
-            return 
-        document.body[j] = document.body[j].replace("\\lang turkmen", "\\lang 
english") 
-        j += 1 
+    j = 0
+    while True:
+        j = find_token(document.body, "\\lang turkmen", j)
+        if j == -1:
+            return
+        document.body[j] = document.body[j].replace("\\lang turkmen", "\\lang 
english")
+        j += 1
 
 
 def revert_fontcolor(document):
@@ -1332,7 +1331,7 @@ def revert_lyx_version(document):
         pass
 
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, '\\begin_inset Info', i)
         if i == -1:
             return
@@ -1406,7 +1405,7 @@ def convert_html_quotes(document):
     m = l.match(line)
     if m:
       document.header[i] = "\\html_latex_start " + m.group(1)
-      
+
   i = find_token(document.header, '\\html_latex_end', 0)
   if i != -1:
     line = document.header[i]
@@ -1414,11 +1413,11 @@ def convert_html_quotes(document):
     m = l.match(line)
     if m:
       document.header[i] = "\\html_latex_end " + m.group(1)
-      
+
 
 def revert_html_quotes(document):
   " Remove quotes around html_latex_start and html_latex_end "
-  
+
   i = find_token(document.header, '\\html_latex_start', 0)
   if i != -1:
     line = document.header[i]
@@ -1429,7 +1428,7 @@ def revert_html_quotes(document):
         del document.header[i]
     else:
         document.header[i] = "\\html_latex_start \"" + m.group(1) + "\""
-      
+
   i = find_token(document.header, '\\html_latex_end', 0)
   if i != -1:
     line = document.header[i]
@@ -1481,7 +1480,7 @@ def revert_align_decimal(document):
 def convert_optarg(document):
   " Convert \\begin_inset OptArg to \\begin_inset Argument "
   i = 0
-  while 1:
+  while True:
     i = find_token(document.body, '\\begin_inset OptArg', i)
     if i == -1:
       return
@@ -1492,7 +1491,7 @@ def convert_optarg(document):
 def revert_argument(document):
   " Convert \\begin_inset Argument to \\begin_inset OptArg "
   i = 0
-  while 1:
+  while True:
     i = find_token(document.body, '\\begin_inset Argument', i)
     if i == -1:
       return
@@ -1503,7 +1502,7 @@ def revert_argument(document):
 def revert_makebox(document):
   " Convert \\makebox to TeX code "
   i = 0
-  while 1:
+  while True:
     i = find_token(document.body, '\\begin_inset Box', i)
     if i == -1:
       break
@@ -1634,8 +1633,8 @@ def convert_prettyref(document):
                        document.body[k] = "LatexCommand formatted"
                i = j + 1
        document.header.insert(-1, "\\use_refstyle 0")
-               
- 
+
+
 def revert_refstyle(document):
        " Reverts neutral formatted refs to prettyref "
        re_ref = re.compile("^reference\s+\"(\w+):(\S+)\"")
@@ -1658,7 +1657,7 @@ def revert_refstyle(document):
        i = find_token(document.header, "\\use_refstyle", 0)
        if i != -1:
                document.header.pop(i)
- 
+
 
 def revert_nameref(document):
   " Convert namerefs to regular references "
@@ -1668,7 +1667,7 @@ def revert_nameref(document):
   for cmd in cmds:
     i = 0
     oldcmd = "LatexCommand " + cmd
-    while 1:
+    while True:
       # It seems better to look for this, as most of the reference
       # insets won't be ones we care about.
       i = find_token(document.body, oldcmd, i)
@@ -1699,13 +1698,13 @@ def revert_nameref(document):
       document.body[stins:endins + 1] = newcontent
 
   if foundone:
-    add_to_preamble(document, ["\usepackage{nameref}"])
+    add_to_preamble(document, ["\\usepackage{nameref}"])
 
 
 def remove_Nameref(document):
   " Convert Nameref commands to nameref commands "
   i = 0
-  while 1:
+  while True:
     # It seems better to look for this, as most of the reference
     # insets won't be ones we care about.
     i = find_token(document.body, "LatexCommand Nameref" , i)
@@ -1713,7 +1712,7 @@ def remove_Nameref(document):
       break
     cmdloc = i
     i += 1
-    
+
     # Make sure it is actually in an inset!
     val = is_in_inset(document.body, cmdloc, \
         "\\begin_inset CommandInset ref")
@@ -1733,7 +1732,7 @@ def revert_mathrsfs(document):
 
 def convert_flexnames(document):
     "Convert \\begin_inset Flex Custom:Style to \\begin_inset Flex Style and 
similarly for CharStyle and Element."
-    
+
     i = 0
     rx = re.compile(r'^\\begin_inset Flex (?:Custom|CharStyle|Element):(.+)$')
     while True:
@@ -1813,7 +1812,7 @@ def revert_flexnames(document):
     flexlist = flex_insets
   else:
     flexlist = flex_elements
-  
+
   rx = re.compile(r'^\\begin_inset Flex\s+(.+)$')
   i = 0
   while True:
@@ -1870,7 +1869,7 @@ def revert_mathdots(document):
         # force load case
         add_to_preamble(document, ["\\usepackage{mathdots}"])
         return
-    
+
     # so we are in the auto case. we want to load mathdots if \iddots is used.
     i = 0
     while True:
@@ -1892,7 +1891,7 @@ def revert_mathdots(document):
 def convert_rule(document):
     " Convert \\lyxline to CommandInset line. "
     i = 0
-    
+
     inset = ['\\begin_inset CommandInset line',
       'LatexCommand rule',
       'offset "0.5ex"',
@@ -1947,7 +1946,7 @@ def convert_rule(document):
 def revert_rule(document):
     " Revert line insets to Tex code "
     i = 0
-    while 1:
+    while True:
       i = find_token(document.body, "\\begin_inset CommandInset line" , i)
       if i == -1:
         return
@@ -1982,7 +1981,7 @@ def revert_diagram(document):
     j = find_end_of_inset(document.body, i)
     if j == -1:
         document.warning("Malformed LyX document: Can't find end of Formula 
inset.")
-        return 
+        return
     lines = "\n".join(document.body[i:j])
     if lines.find("\\Diagram") == -1:
       i = j
@@ -1991,9 +1990,9 @@ def revert_diagram(document):
     # only need to do it once!
     return
 
-chapters = ("amsbook", "book", "docbook-book", "elsart", "extbook", 
"extreport", 
-    "jbook", "jreport", "jsbook", "literate-book", "literate-report", 
"memoir", 
-    "mwbk", "mwrep", "recipebook", "report", "scrbook", "scrreprt", "svmono", 
+chapters = ("amsbook", "book", "docbook-book", "elsart", "extbook", 
"extreport",
+    "jbook", "jreport", "jsbook", "literate-book", "literate-report", "memoir",
+    "mwbk", "mwrep", "recipebook", "report", "scrbook", "scrreprt", "svmono",
     "svmult", "tbook", "treport", "tufte-book")
 
 def convert_bibtex_clearpage(document):
@@ -2037,13 +2036,13 @@ def convert_bibtex_clearpage(document):
       document.warning("Can't find options for bibliography inset at line " + 
str(j))
       j = k
       continue
-    
+
     if val.find("bibtotoc") == -1:
       j = k
       continue
-    
+
     # so we want to insert a new page right before the paragraph that
-    # this bibliography thing is in. 
+    # this bibliography thing is in.
     lay = find_token_backwards(document.body, "\\begin_layout", j)
     if lay == -1:
       document.warning("Can't find layout containing bibliography inset at 
line " + str(j))
@@ -2078,7 +2077,7 @@ def convert_passthru(document):
     " http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg161298.html "
     if not check_passthru:
       return
-    
+
     rx = re.compile("\\\\begin_layout \s*(\w+)")
     beg = 0
     for lay in ["Chunk", "Scrap"]:
@@ -2137,7 +2136,7 @@ def convert_passthru(document):
         beg = end + 1
         if didit:
           beg += 4 # for the extra layout
-    
+
 
 def revert_passthru(document):
     " http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg161298.html "
@@ -2155,7 +2154,7 @@ def revert_passthru(document):
           document.warning("Can't find end of layout at line " + str(beg))
           beg += 1
           continue
-        
+
         # we now want to find out if the next layout is the
         # same as this one. but we will need to do this over and
         # over again.
@@ -2173,7 +2172,6 @@ def revert_passthru(document):
           # but first let's check and make sure there is no content between the
           # two layouts. i'm not sure if that can happen or not.
           for l in range(end + 1, next):
-            document.warning("c'" + document.body[l] + "'")
             if document.body[l] != "":
               document.warning("Found content between adjacent " + lay + " 
layouts!")
               break
@@ -2183,7 +2181,6 @@ def revert_passthru(document):
             break
           empty = True
           for l in range(next + 1, nextend):
-            document.warning("e'" + document.body[l] + "'")
             if document.body[l] != "":
               empty = False
               break
@@ -2238,7 +2235,7 @@ def revert_multirowOffset(document):
         if i == -1:
             begin_table = end_table
             continue
-        
+
         # store the number of rows and columns
         numrows = get_option_value(document.body[begin_table], "rows")
         numcols = get_option_value(document.body[begin_table], "columns")
@@ -2265,13 +2262,13 @@ def revert_multirowOffset(document):
               break
             begin_cell = begin_row
             multirows.append([])
-            for column in range(numcols):            
+            for column in range(numcols):
                 begin_cell = find_token(document.body, '<cell ', begin_cell, 
end_row)
                 if begin_cell == -1:
                   document.warning("Can't find column " + str(column + 1) + \
                     "in row " + str(row + 1))
                   break
-                # NOTE 
+                # NOTE
                 # this will fail if someone puts "</cell>" in a cell, but
                 # that seems fairly unlikely.
                 end_cell = find_end_of(document.body, begin_cell, '<cell', 
'</cell>')
@@ -2323,7 +2320,7 @@ def revert_multirowOffset(document):
               replace('valignment="middle"', 'valignment="top"')
             # remove mroffset option
             document.body[bcell] = rgx.sub('', document.body[bcell])
-            
+
             blay = find_token(document.body, "\\begin_layout", bcell, ecell)
             if blay == -1:
               document.warning("Can't find layout for cell!")
@@ -2349,7 +2346,7 @@ def revert_script(document):
     " Convert subscript/superscript inset to TeX code "
     i = 0
     foundsubscript = False
-    while 1:
+    while True:
         i = find_token(document.body, '\\begin_inset script', i)
         if i == -1:
             break
diff --git 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_2_0-113c9a2.001.py" 
"b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_2_0.py"
index 1f10154440..324c4130b8 100644
--- 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_2_0-113c9a2.001.py"
+++ "b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_2_0.py"
@@ -1503,7 +1503,7 @@ def revert_argument(document):
 def revert_makebox(document):
   " Convert \\makebox to TeX code "
   i = 0
-  while 1:
+  while True:
     i = find_token(document.body, '\\begin_inset Box', i)
     if i == -1:
       break
@@ -1517,17 +1517,16 @@ def revert_makebox(document):
       document.warning("Malformed LyX document: Can't find layout in box.")
       i = z
       continue
-    # by looking before the layout we make sure we're actually finding
-    # an option, not text.
-    j = find_token(document.body, 'use_makebox', i, blay)
-    if j == -1:
-        i = z
-        continue
-    
+    j = find_token(document.body, 'use_makebox', i)
+    if j == -1 or j != i +6:
+      document.warning("Malformed LyX document: Can't find use_makebox 
statement in box.")
+      i = z
+      continue
+    # delete use_makebox
     if not check_token(document.body[i], "\\begin_inset Box Frameless") \
       or get_value(document.body, 'use_makebox', j) != 1:
         del document.body[j]
-        i = z
+        i += 1
         continue
     bend = find_end_of_layout(document.body, blay)
     if bend == -1 or bend > z:
@@ -1550,30 +1549,18 @@ def revert_makebox(document):
 def convert_use_makebox(document):
   " Adds use_makebox option for boxes "
   i = 0
-  while 1:
+  while True:
     i = find_token(document.body, '\\begin_inset Box', i)
     if i == -1:
       return
-    # all of this is to make sure we actually find the use_parbox
-    # that is an option for this box, not some text elsewhere.
-    z = find_end_of_inset(document.body, i)
-    if z == -1:
-      document.warning("Can't find end of box inset!!")
-      i += 1
-      continue
-    blay = find_token(document.body, "\\begin_layout", i, z)
-    if blay == -1:
-      document.warning("Can't find layout in box inset!!")
-      i = z
-      continue
-    # so now we are looking for use_parbox before the box's layout
-    k = find_token(document.body, 'use_parbox', i, blay)
-    if k == -1:
+    k = find_token(document.body, 'use_parbox', i)
+    if k == -1 or k != i + 5:
       document.warning("Malformed LyX document: Can't find use_parbox 
statement in box.")
-      i = z
+      i += 1
       continue
-    document.body.insert(k + 1, "use_makebox 0")
-    i = blay + 1 # not z + 1 (box insets may be nested)
+    if k == i + 5:
+      document.body.insert(k + 1, "use_makebox 0")
+    i += 1
 
 
 def revert_IEEEtran(document):
diff --git 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_2_2-113c9a2.000.py" 
"b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_2_2.py"
index c30477de17..27593bf36e 100644
--- 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_2_2-113c9a2.000.py"
+++ "b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_2_2.py"
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 # This file is part of lyx2lyx
-# -*- coding: utf-8 -*-
 # Copyright (C) 2015 The LyX team
 #
 # This program is free software; you can redistribute it and/or
@@ -78,7 +77,7 @@ def revert_Argument_to_TeX_brace(document, line, endline, n, 
nmax, environment,
             if nolastopt == False:
               document.body[endInset - 2 : endInset + 1] = put_cmd_in_ert("}{")
             else:
-              document.body[endInset - 2 : endInset + 1] = put_cmd_in_ert("}") 
+              document.body[endInset - 2 : endInset + 1] = put_cmd_in_ert("}")
             del(document.body[lineArg : beginPlain + 1])
             wasOpt = False
           else:
@@ -153,7 +152,7 @@ def convert_separator(document):
         }
 
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_deeper", i)
         if i == -1:
             break
@@ -175,7 +174,7 @@ def convert_separator(document):
             i = i + 1
 
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\align", i)
         if i == -1:
             break
@@ -208,7 +207,7 @@ def convert_separator(document):
     regexp = re.compile(r'^\\begin_layout 
(?:(-*)|(\s*))(Separator|EndOfSlide)(?:(-*)|(\s*))$', re.IGNORECASE)
 
     i = 0
-    while 1:
+    while True:
         i = find_re(document.body, regexp, i)
         if i == -1:
             return
@@ -249,7 +248,7 @@ def revert_separator(document):
               "", "\\end_inset", ""]
 
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset Separator", i)
         if i == -1:
             return
@@ -341,7 +340,7 @@ def convert_parbreak(document):
     """
     parbreakinset = "\\begin_inset Separator parbreak"
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, parbreakinset, i)
         if i == -1:
             return
@@ -366,7 +365,7 @@ def revert_parbreak(document):
     Revert latexpar separators to parbreak separators.
     """
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset Separator latexpar", i)
         if i == -1:
             return
@@ -1211,7 +1210,7 @@ def revert_textcolor(document):
                     j = find_token(document.body, "\\color", i + 1)
                     k = find_token(document.body, "\\end_layout", i + 1)
                     if j == -1 and k != -1:
-                        j = k +1 
+                        j = k +1
                     # output TeX code
                     # first output the closing brace
                     if k < j:
@@ -1237,7 +1236,7 @@ def convert_colorbox(document):
 
 def revert_colorbox(document):
     " outputs color settings for boxes as TeX code "
-
+    
     i = 0
     defaultframecolor = "black"
     defaultbackcolor = "none"
@@ -1881,7 +1880,7 @@ def revert_tcolorbox_8(document):
 
 def revert_moderncv_1(document):
   " Reverts the new inset of moderncv to TeX-code in preamble "
-  
+
   if document.textclass != "moderncv":
     return
   i = 0
@@ -1949,7 +1948,7 @@ def revert_moderncv_1(document):
 
 def revert_moderncv_2(document):
   " Reverts the phone inset of moderncv to the obsoleted mobile or fax "
-  
+
   if document.textclass != "moderncv":
     return
   i = 0
@@ -2091,7 +2090,7 @@ def convert_moderncv_name(document):
 
 def revert_achemso(document):
   " Reverts the flex inset Latin to TeX code "
-  
+
   if document.textclass != "achemso":
     return
   i = 0
diff --git 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_2_1-113c9a2.000.py" 
"b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_2_1.py"
index 259d51e328..f56d3adbc8 100644
--- 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_2_1-113c9a2.000.py"
+++ "b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_2_1.py"
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 # This file is part of lyx2lyx
-# -*- coding: utf-8 -*-
 # Copyright (C) 2011 The LyX team
 #
 # This program is free software; you can redistribute it and/or
@@ -117,7 +116,7 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, 
inset, environment, o
     isInset must be true, if braces inside an InsetLayout needs to be converted
     isEnvironment must be true, if the layout is for a LaTeX environment
     isOpt must be true, if the argument is an optional one
-    
+
     Todo: this routine can currently handle only one mandatory argument of 
environments
     '''
 
@@ -168,7 +167,7 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, 
inset, environment, o
           n += 1
           endn = end
           loop += 1
-        else: 
+        else:
           # no brace pair found
           # now check the case that we have "}" + "{" in two ERTs
           if opt:
@@ -449,16 +448,16 @@ def revert_justification(document):
 
 
 def revert_australian(document):
-    "Set English language variants Australian and Newzealand to English" 
+    "Set English language variants Australian and Newzealand to English"
 
-    if document.language == "australian" or document.language == "newzealand": 
+    if document.language == "australian" or document.language == "newzealand":
         document.language = "english"
-        i = find_token(document.header, "\\language", 0) 
-        if i != -1: 
-            document.header[i] = "\\language english" 
-    j = 0 
-    while True: 
-        j = find_token(document.body, "\\lang australian", j) 
+        i = find_token(document.header, "\\language", 0)
+        if i != -1:
+            document.header[i] = "\\language english"
+    j = 0
+    while True:
+        j = find_token(document.body, "\\lang australian", j)
         if j == -1:
             j = find_token(document.body, "\\lang newzealand", 0)
             if j == -1:
@@ -466,7 +465,7 @@ def revert_australian(document):
             else:
                 document.body[j] = document.body[j].replace("\\lang 
newzealand", "\\lang english")
         else:
-            document.body[j] = document.body[j].replace("\\lang australian", 
"\\lang english") 
+            document.body[j] = document.body[j].replace("\\lang australian", 
"\\lang english")
         j += 1
 
 
@@ -565,7 +564,7 @@ def handle_longtable_captions(document, forward):
                 if get_option_value(document.body[begin_row], 'endlastfoot') 
== 'true':
                     document.body[begin_row] = 
set_option_value(document.body[begin_row], 'endlastfoot', 'false')
             begin_row = end_row
-        # since there could be a tabular inside this one, we 
+        # since there could be a tabular inside this one, we
         # cannot jump to end.
         begin_table += 1
 
@@ -848,7 +847,7 @@ def revert_verbatim(document, starred = False):
                    'begin{%s}' % (latex_name),
                    '\\end_layout', '', '\\begin_layout Plain Layout', '']
 
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_layout %s" % (layout_name), i)
         if i == -1:
             return
@@ -860,7 +859,7 @@ def revert_verbatim(document, starred = False):
             continue
         # delete all line breaks insets (there are no other insets)
         l = i
-        while 1:
+        while True:
             n = find_token(document.body, "\\begin_inset Newline newline", l, 
j)
             if n == -1:
                 n = find_token(document.body, "\\begin_inset Newline 
linebreak", l, j)
@@ -908,7 +907,7 @@ def revert_verbatim(document, starred = False):
 def revert_tipa(document):
     " Revert native TIPA insets to mathed or ERT. "
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset IPA", i)
         if i == -1:
             return
@@ -975,12 +974,12 @@ def revert_cell_rotation(document):
             put_cmd_in_ert("\\end{turn}")
           document.body[i + 4 : i + 4] = \
             put_cmd_in_ert("\\begin{turn}{" + value + "}")
-        
+
       i += 1
-        
+
   finally:
     if load_rotating:
-      add_to_preamble(document, 
["\\@ifundefined{turnbox}{\usepackage{rotating}}{}"])
+      add_to_preamble(document, 
["\\@ifundefined{turnbox}{\\usepackage{rotating}}{}"])
 
 
 def convert_cell_rotation(document):
@@ -997,7 +996,7 @@ def convert_cell_rotation(document):
         rgx = re.compile(r'rotate="[^"]+?"')
         # convert "true" to "90"
         document.body[i] = rgx.sub('rotate="90"', document.body[i])
-        
+
       i += 1
 
 
@@ -1034,12 +1033,12 @@ def revert_table_rotation(document):
             put_cmd_in_ert("\\end{turn}")
           document.body[i - 2 : i - 2] = \
             put_cmd_in_ert("\\begin{turn}{" + value + "}")
-        
+
       i += 1
-        
+
   finally:
     if load_rotating:
-      add_to_preamble(document, 
["\\@ifundefined{turnbox}{\usepackage{rotating}}{}"])
+      add_to_preamble(document, 
["\\@ifundefined{turnbox}{\\usepackage{rotating}}{}"])
 
 
 def convert_table_rotation(document):
@@ -1056,7 +1055,7 @@ def convert_table_rotation(document):
         rgx = re.compile(r'rotate="[^"]+?"')
         # convert "true" to "90"
         document.body[i] = rgx.sub('rotate="90"', document.body[i])
-        
+
       i += 1
 
 
@@ -1150,25 +1149,25 @@ def revert_use_cancel(document):
 
 
 def revert_ancientgreek(document):
-    "Set the document language for ancientgreek to greek" 
+    "Set the document language for ancientgreek to greek"
 
-    if document.language == "ancientgreek": 
+    if document.language == "ancientgreek":
         document.language = "greek"
-        i = find_token(document.header, "\\language", 0) 
-        if i != -1: 
-            document.header[i] = "\\language greek" 
-    j = 0 
-    while True: 
-        j = find_token(document.body, "\\lang ancientgreek", j) 
+        i = find_token(document.header, "\\language", 0)
+        if i != -1:
+            document.header[i] = "\\language greek"
+    j = 0
+    while True:
+        j = find_token(document.body, "\\lang ancientgreek", j)
         if j == -1:
             return
         else:
-            document.body[j] = document.body[j].replace("\\lang ancientgreek", 
"\\lang greek") 
+            document.body[j] = document.body[j].replace("\\lang ancientgreek", 
"\\lang greek")
         j += 1
 
 
 def revert_languages(document):
-    "Set the document language for new supported languages to English" 
+    "Set the document language for new supported languages to English"
 
     languages = [
                  "coptic", "divehi", "hindi", "kurmanji", "lao", "marathi", 
"occitan", "sanskrit",
@@ -1177,11 +1176,11 @@ def revert_languages(document):
     for n in range(len(languages)):
         if document.language == languages[n]:
             document.language = "english"
-            i = find_token(document.header, "\\language", 0) 
-            if i != -1: 
-                document.header[i] = "\\language english" 
+            i = find_token(document.header, "\\language", 0)
+            if i != -1:
+                document.header[i] = "\\language english"
         j = 0
-        while j < len(document.body): 
+        while j < len(document.body):
             j = find_token(document.body, "\\lang " + languages[n], j)
             if j != -1:
                 document.body[j] = document.body[j].replace("\\lang " + 
languages[n], "\\lang english")
@@ -1191,27 +1190,27 @@ def revert_languages(document):
 
 
 def convert_armenian(document):
-    "Use polyglossia and thus non-TeX fonts for Armenian" 
+    "Use polyglossia and thus non-TeX fonts for Armenian"
 
-    if document.language == "armenian": 
-        i = find_token(document.header, "\\use_non_tex_fonts", 0) 
-        if i != -1: 
-            document.header[i] = "\\use_non_tex_fonts true" 
+    if document.language == "armenian":
+        i = find_token(document.header, "\\use_non_tex_fonts", 0)
+        if i != -1:
+            document.header[i] = "\\use_non_tex_fonts true"
 
 
 def revert_armenian(document):
-    "Use ArmTeX and thus TeX fonts for Armenian" 
+    "Use ArmTeX and thus TeX fonts for Armenian"
 
-    if document.language == "armenian": 
-        i = find_token(document.header, "\\use_non_tex_fonts", 0) 
-        if i != -1: 
-            document.header[i] = "\\use_non_tex_fonts false" 
+    if document.language == "armenian":
+        i = find_token(document.header, "\\use_non_tex_fonts", 0)
+        if i != -1:
+            document.header[i] = "\\use_non_tex_fonts false"
 
 
 def revert_libertine(document):
-    " Revert native libertine font definition to LaTeX " 
+    " Revert native libertine font definition to LaTeX "
 
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         i = find_token(document.header, "\\font_roman libertine", 0)
         if i != -1:
             osf = False
@@ -1230,9 +1229,9 @@ def revert_libertine(document):
 
 
 def revert_txtt(document):
-    " Revert native txtt font definition to LaTeX " 
+    " Revert native txtt font definition to LaTeX "
 
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         i = find_token(document.header, "\\font_typewriter txtt", 0)
         if i != -1:
             preamble = "\\renewcommand{\\ttdefault}{txtt}"
@@ -1241,9 +1240,9 @@ def revert_txtt(document):
 
 
 def revert_mathdesign(document):
-    " Revert native mathdesign font definition to LaTeX " 
+    " Revert native mathdesign font definition to LaTeX "
 
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         mathdesign_dict = {
         "mdbch":  "charter",
         "mdput":  "utopia",
@@ -1272,9 +1271,9 @@ def revert_mathdesign(document):
 
 
 def revert_texgyre(document):
-    " Revert native TeXGyre font definition to LaTeX " 
+    " Revert native TeXGyre font definition to LaTeX "
 
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         texgyre_fonts = ["tgadventor", "tgbonum", "tgchorus", "tgcursor", \
                          "tgheros", "tgpagella", "tgschola", "tgtermes"]
         i = find_token(document.header, "\\font_roman", 0)
@@ -1331,7 +1330,7 @@ def revert_ipadeco(document):
           i = end
           continue
       substi = ["\\begin_inset ERT", "status collapsed", "",
-                "\\begin_layout Plain Layout", "", "", "\\backslash", 
+                "\\begin_layout Plain Layout", "", "", "\\backslash",
                 decotype + "{", "\\end_layout", "", "\\end_inset"]
       substj = ["\\size default", "", "\\begin_inset ERT", "status collapsed", 
"",
                 "\\begin_layout Plain Layout", "", "}", "\\end_layout", "", 
"\\end_inset"]
@@ -1371,9 +1370,9 @@ def revert_ipachar(document):
 
 
 def revert_minionpro(document):
-    " Revert native MinionPro font definition to LaTeX " 
+    " Revert native MinionPro font definition to LaTeX "
 
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         i = find_token(document.header, "\\font_roman minionpro", 0)
         if i != -1:
             osf = False
@@ -1391,12 +1390,12 @@ def revert_minionpro(document):
 
 
 def revert_mathfonts(document):
-    " Revert native math font definitions to LaTeX " 
+    " Revert native math font definitions to LaTeX "
 
     i = find_token(document.header, "\\font_math", 0)
     if i == -1:
        return
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         val = get_value(document.header, "\\font_math", i)
         if val == "eulervm":
             add_to_preamble(document, "\\usepackage{eulervm}")
@@ -1426,9 +1425,9 @@ def revert_mathfonts(document):
 
 
 def revert_mdnomath(document):
-    " Revert mathdesign and fourier without math " 
+    " Revert mathdesign and fourier without math "
 
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         mathdesign_dict = {
         "md-charter": "mdbch",
         "md-utopia": "mdput",
@@ -1455,9 +1454,9 @@ def convert_mathfonts(document):
 
 
 def convert_mdnomath(document):
-    " Change mathdesign font name " 
+    " Change mathdesign font name "
 
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         mathdesign_dict = {
         "mdbch":  "md-charter",
         "mdput":  "md-utopia",
@@ -1472,12 +1471,12 @@ def convert_mdnomath(document):
 
 
 def revert_newtxmath(document):
-    " Revert native newtxmath definitions to LaTeX " 
+    " Revert native newtxmath definitions to LaTeX "
 
     i = find_token(document.header, "\\font_math", 0)
     if i == -1:
        return
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         val = get_value(document.header, "\\font_math", i)
         mathfont_dict = {
         "libertine-ntxm":  "\\usepackage[libertine]{newtxmath}",
@@ -1490,9 +1489,9 @@ def revert_newtxmath(document):
 
 
 def revert_biolinum(document):
-    " Revert native biolinum font definition to LaTeX " 
+    " Revert native biolinum font definition to LaTeX "
 
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         i = find_token(document.header, "\\font_sans biolinum", 0)
         if i != -1:
             osf = False
@@ -1595,7 +1594,7 @@ def convert_latexargs(document):
             document.body[i] = "\\begin_inset Argument 999"
             i += 1
             continue
-        
+
         # Find containing paragraph layout
         parent = get_containing_layout(document.body, i)
         if parent == False:
@@ -2174,7 +2173,7 @@ def revert_literate(document):
 
 def convert_literate(document):
     " Convert Literate document to new format"
-    i = find_token(document.header, "\\textclass", 0)    
+    i = find_token(document.header, "\\textclass", 0)
     if (i != -1) and "literate-" in document.header[i]:
       document.textclass = document.header[i].replace("\\textclass literate-", 
"")
       j = find_token(document.header, "\\begin_modules", 0)
@@ -2218,12 +2217,12 @@ def revert_itemargs(document):
 
 
 def revert_garamondx_newtxmath(document):
-    " Revert native garamond newtxmath definition to LaTeX " 
+    " Revert native garamond newtxmath definition to LaTeX "
 
     i = find_token(document.header, "\\font_math", 0)
     if i == -1:
        return
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         val = get_value(document.header, "\\font_math", i)
         if val == "garamondx-ntxm":
             add_to_preamble(document, "\\usepackage[garamondx]{newtxmath}")
@@ -2231,9 +2230,9 @@ def revert_garamondx_newtxmath(document):
 
 
 def revert_garamondx(document):
-    " Revert native garamond font definition to LaTeX " 
+    " Revert native garamond font definition to LaTeX "
 
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
         i = find_token(document.header, "\\font_roman garamondx", 0)
         if i != -1:
             osf = False
@@ -2250,7 +2249,7 @@ def revert_garamondx(document):
 
 def convert_beamerargs(document):
     " Converts beamer arguments to new layout "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -2421,7 +2420,7 @@ def convert_againframe_args(document):
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
-   
+
     i = 0
     while True:
         i = find_token(document.body, "\\begin_layout AgainFrame", i)
@@ -2443,11 +2442,11 @@ def convert_againframe_args(document):
 
 def convert_corollary_args(document):
     " Converts beamer corrolary-style ERT arguments native InsetArgs "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
-   
+
     corollary_layouts = ["Corollary", "Definition", "Definitions", "Example", 
"Examples", "Fact", "Proof", "Theorem"]
     for lay in corollary_layouts:
         i = 0
@@ -2533,11 +2532,11 @@ def convert_corollary_args(document):
 
 def convert_quote_args(document):
     " Converts beamer quote style ERT args to native InsetArgs "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
-   
+
     quote_layouts = ["Uncover", "Only", "Quotation", "Quote", "Verse"]
     for lay in quote_layouts:
         i = 0
@@ -2602,7 +2601,7 @@ def cleanup_beamerargs(document):
 
 def revert_beamerargs(document):
     " Reverts beamer arguments to old layout "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -2793,13 +2792,13 @@ def revert_beamerargs(document):
                         del document.body[p : endInset + 1]
                         subst = put_cmd_in_ert("[") + content + 
put_cmd_in_ert("]")
                         document.body[realparbeg : realparbeg] = subst
-        
+
         i = realparend
 
 
 def revert_beamerargs2(document):
     " Reverts beamer arguments to old layout, step 2 "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -2833,7 +2832,7 @@ def revert_beamerargs2(document):
                 if m:
                     argnr = m.group(1)
                     if argnr == "2":
-                        document.body[p] = "\\begin_inset Argument 1"       
+                        document.body[p] = "\\begin_inset Argument 1"
             if layoutname in corollary_layouts:
                 m = rx.match(document.body[p])
                 if m:
@@ -2884,7 +2883,7 @@ def revert_beamerargs2(document):
 
 def revert_beamerargs3(document):
     " Reverts beamer arguments to old layout, step 3 "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -2930,7 +2929,7 @@ def revert_beamerargs3(document):
 
 def revert_beamerflex(document):
     " Reverts beamer Flex insets "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -3030,13 +3029,13 @@ def revert_beamerflex(document):
                 document.body[i : beginPlain + 1] = pre
                 post = put_cmd_in_ert("}")
                 document.body[z - 2 : z + 1] = post
-        
+
         i += 1
 
 
 def revert_beamerblocks(document):
     " Reverts beamer block arguments to ERT "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -3096,11 +3095,11 @@ def revert_beamerblocks(document):
 
 def convert_beamerblocks(document):
     " Converts beamer block ERT args to native InsetArgs "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
-   
+
     blocks = ["Block", "ExampleBlock", "AlertBlock"]
     for lay in blocks:
         i = 0
@@ -3211,7 +3210,7 @@ def convert_beamerblocks(document):
                                                 document.body[ertcontlastline 
: ertcontlastline + 1] = [
                                                                                
     document.body[ertcontlastline], '\\end_layout', '', '\\end_inset']
                                                 document.body[ertcontdivline : 
ertcontdivlinetwo + 1] = [document.body[ertcontdivline][:tok],
-                                                                               
     '\\end_layout', '', '\\end_inset', '', '\\end_layout', '', 
+                                                                               
     '\\end_layout', '', '\\end_inset', '', '\\end_layout', '',
                                                                                
     '\\end_inset', '', '', '\\begin_inset Argument 2',
                                                                                
     'status collapsed', '', '\\begin_layout Plain Layout',
                                                                                
     '\\begin_inset ERT', '', 'status open' '', '\\begin_layout Plain Layout',
@@ -3300,7 +3299,7 @@ def convert_beamerblocks(document):
                                                         
document.body[ertcontlastline : ertcontlastline + 1] = [
                                                                                
             document.body[ertcontlastline], '\\end_layout', '', '\\end_inset']
                                                         
document.body[ertcontdivline : ertcontdivlinetwo + 1] = 
[document.body[ertcontdivline][:tok],
-                                                                               
             '\\end_layout', '', '\\end_inset', '', '\\end_layout', '', 
+                                                                               
             '\\end_layout', '', '\\end_inset', '', '\\end_layout', '',
                                                                                
             '\\end_inset', '', '', '\\begin_inset Argument 1',
                                                                                
             'status collapsed', '', '\\begin_layout Plain Layout',
                                                                                
             '\\begin_inset ERT', '', 'status open' '', '\\begin_layout Plain 
Layout',
@@ -3346,7 +3345,7 @@ def convert_beamerblocks(document):
 
 def convert_overprint(document):
     " Convert old beamer overprint layouts to ERT "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -3386,11 +3385,11 @@ def convert_overprint(document):
             # Remove arg inset
             del document.body[argbeg : argend + 1]
             subst += put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
-            
+
         endseq = endseq - len(document.body[i : i])
         document.body[i : i] = subst + ["\\end_layout"]
         endseq += len(subst)
-        
+
         for p in range(i, endseq):
             if document.body[p] == "\\begin_layout Overprint":
                 document.body[p] = "\\begin_layout Standard"
@@ -3400,7 +3399,7 @@ def convert_overprint(document):
 
 def revert_overprint(document):
     " Revert old beamer overprint layouts to ERT "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -3452,11 +3451,11 @@ def revert_overprint(document):
                 # Remove arg inset
                 del document.body[argbeg : argend + 1]
                 subst += put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
-            
+
         endseq = endseq - len(document.body[i : i])
         document.body[i : i] = subst + ["\\end_layout"]
         endseq += len(subst)
-     
+
         p = i
         while True:
             if p >= endseq:
@@ -3492,7 +3491,7 @@ def revert_overprint(document):
 
 def revert_frametitle(document):
     " Reverts beamer frametitle layout to ERT "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -3538,7 +3537,7 @@ def revert_frametitle(document):
                     # Remove arg inset
                     del document.body[p : endInset + 1]
                     subst += put_cmd_in_ert("[") + content + 
put_cmd_in_ert("]")
-                    
+
         subst += put_cmd_in_ert("{")
         document.body[i : i + 1] = subst
         i = endlay
@@ -3546,7 +3545,7 @@ def revert_frametitle(document):
 
 def convert_epigraph(document):
     " Converts memoir epigraph to new syntax "
-    
+
     if document.textclass != "memoir":
         return
 
@@ -3581,13 +3580,13 @@ def convert_epigraph(document):
                 endlay += len(begsubst) + len(endsubst)
                 endlay = endlay - len(document.body[ert : endInset + 1])
                 del document.body[ert : endInset + 1]
-                    
+
         i = endlay
 
 
 def revert_epigraph(document):
     " Reverts memoir epigraph argument to ERT "
-    
+
     if document.textclass != "memoir":
         return
 
@@ -3616,14 +3615,14 @@ def revert_epigraph(document):
             subst += put_cmd_in_ert("}{") + content
         else:
             subst += put_cmd_in_ert("}{")
-                    
+
         document.body[j : j] = subst + document.body[j : j]
         i = endlay
 
 
 def convert_captioninsets(document):
     " Converts caption insets to new syntax "
-    
+
     i = 0
     while True:
       i = find_token(document.body, "\\begin_inset Caption", i)
@@ -3635,7 +3634,7 @@ def convert_captioninsets(document):
 
 def revert_captioninsets(document):
     " Reverts caption insets to old syntax "
-    
+
     i = 0
     while True:
       i = find_token(document.body, "\\begin_inset Caption Standard", i)
@@ -3678,7 +3677,7 @@ def convert_captionlayouts(document):
 
 def revert_captionlayouts(document):
     " Revert caption insets to caption layouts. "
-    
+
     caption_dict = {
         "Above" : "Captionabove",
         "Below" : "Captionbelow",
@@ -3687,7 +3686,7 @@ def revert_captionlayouts(document):
         "Centered" : "CenteredCaption",
         "Bicaption" : "Bicaption",
         }
-    
+
     i = 0
     rx = re.compile(r'^\\begin_inset Caption (\S+)$')
     while True:
@@ -3702,7 +3701,7 @@ def revert_captionlayouts(document):
         if val not in list(caption_dict.keys()):
             i += 1
             continue
-        
+
         # We either need to delete the previous \begin_layout line, or we
         # need to end the previous layout if this inset is not in the first
         # position of the paragraph.
@@ -3770,7 +3769,7 @@ def revert_captionlayouts(document):
 
 def revert_fragileframe(document):
     " Reverts beamer FragileFrame layout to ERT "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -3852,14 +3851,14 @@ def revert_fragileframe(document):
                     subst += put_cmd_in_ert("{") + content + 
put_cmd_in_ert("}")
             elif p == 3:
                 subst += put_cmd_in_ert("[fragile]")
-                    
+
         document.body[i : i + 1] = subst
         i = j
 
 
 def revert_newframes(document):
     " Reverts beamer Frame and PlainFrame layouts to old forms "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
@@ -3954,7 +3953,7 @@ def revert_newframes(document):
                     # Remove arg inset
                     del document.body[arg : endInset + 1]
                     subst += content
-                    
+
         document.body[i : i + 1] = subst
         i = j
 
@@ -4079,18 +4078,18 @@ def revert_IEEEtran_3(document):
 
 def revert_kurier_fonts(document):
   " Revert kurier font definition to LaTeX "
-  
+
   i = find_token(document.header, "\\font_math", 0)
   if i != -1:
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
       val = get_value(document.header, "\\font_math", i)
       if val == "kurier-math":
         add_to_preamble(document, "\\let\\Myrmdefault\\rmdefault\n" \
           "\\usepackage[math]{kurier}\n" \
           "\\renewcommand{\\rmdefault}{\\Myrmdefault}")
         document.header[i] = "\\font_math auto"
-  
-  if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+
+  if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
     kurier_fonts = ["kurier", "kurierc", "kurierl", "kurierlc"]
     k = find_token(document.header, "\\font_sans kurier", 0)
     if k != -1:
@@ -4101,18 +4100,18 @@ def revert_kurier_fonts(document):
 
 def revert_iwona_fonts(document):
   " Revert iwona font definition to LaTeX "
-  
+
   i = find_token(document.header, "\\font_math", 0)
   if i != -1:
-    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+    if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
       val = get_value(document.header, "\\font_math", i)
       if val == "iwona-math":
         add_to_preamble(document, "\\let\\Myrmdefault\\rmdefault\n" \
           "\\usepackage[math]{iwona}\n" \
           "\\renewcommand{\\rmdefault}{\\Myrmdefault}")
         document.header[i] = "\\font_math auto"
-  
-  if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1: 
+
+  if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
     iwona_fonts = ["iwona", "iwonac", "iwonal", "iwonalc"]
     k = find_token(document.header, "\\font_sans iwona", 0)
     if k != -1:
@@ -4124,7 +4123,7 @@ def revert_iwona_fonts(document):
 
 def revert_new_libertines(document):
     " Revert new libertine font definition to LaTeX "
-  
+
     if find_token(document.header, "\\use_non_tex_fonts true", 0) != -1:
         return
 
@@ -4140,7 +4139,7 @@ def revert_new_libertines(document):
         preamble += "{libertineMono-type1}"
         add_to_preamble(document, [preamble])
         document.header[i] = "\\font_typewriter default"
-   
+
     k = find_token(document.header, "\\font_sans biolinum", 0)
     if k != -1:
         preamble = "\\usepackage"
@@ -4165,11 +4164,11 @@ def revert_new_libertines(document):
 
 def convert_lyxframes(document):
     " Converts old beamer frames to new style "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
-   
+
     framebeg = ["BeginFrame", "BeginPlainFrame"]
     frameend = ["Frame", "PlainFrame", "EndFrame", "BeginFrame", 
"BeginPlainFrame", "AgainFrame",
                 "Section", "Section*", "Subsection", "Subsection*", 
"Subsubsection", "Subsubsection*"]
@@ -4238,11 +4237,11 @@ def convert_lyxframes(document):
 
 def remove_endframes(document):
     " Remove deprecated beamer endframes "
-    
+
     beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
     if document.textclass not in beamer_classes:
         return
-   
+
     i = 0
     while True:
         i = find_token_exact(document.body, "\\begin_layout EndFrame", i)
@@ -4258,7 +4257,7 @@ def remove_endframes(document):
 
 def revert_powerdot_flexes(document):
     " Reverts powerdot flex insets "
-    
+
     if document.textclass != "powerdot":
         return
 
@@ -4306,13 +4305,13 @@ def revert_powerdot_flexes(document):
                 z += len(pre)
                 document.body[i : beginPlain + 1] = pre
                 post = put_cmd_in_ert("}")
-                document.body[z - 2 : z + 1] = post     
+                document.body[z - 2 : z + 1] = post
         i += 1
 
 
 def revert_powerdot_pause(document):
     " Reverts powerdot pause layout to ERT "
-    
+
     if document.textclass != "powerdot":
         return
 
@@ -4342,14 +4341,14 @@ def revert_powerdot_pause(document):
                 # Remove arg inset
                 del document.body[p : endInset + 1]
                 subst += put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
-                    
+
         document.body[i : i + 1] = subst
         i = endlay
 
 
 def revert_powerdot_itemargs(document):
     " Reverts powerdot item arguments to ERT "
-    
+
     if document.textclass != "powerdot":
         return
 
@@ -4398,7 +4397,7 @@ def revert_powerdot_itemargs(document):
                         del document.body[i:j+1]
                         subst = put_cmd_in_ert("<") + content + 
put_cmd_in_ert(">")
                         document.body[realparbeg : realparbeg] = subst
-        
+
         i = realparend
 
 
@@ -4448,7 +4447,7 @@ def revert_powerdot_columns(document):
                     # Remove arg inset
                     del document.body[p : endInset + 1]
                     subst += put_cmd_in_ert("{") + content + 
put_cmd_in_ert("}")
-                    
+
         subst += put_cmd_in_ert("{")
         document.body[i : i + 1] = subst
         i = endlay
@@ -4485,7 +4484,7 @@ def revert_mbox_fbox(document):
 
 def revert_starred_caption(document):
     " Reverts unnumbered longtable caption insets "
-    
+
     i = 0
     while True:
       i = find_token(document.body, "\\begin_inset Caption LongTableNoNumber", 
i)
@@ -4560,15 +4559,15 @@ def revert_aa2(document):
 
 
 def revert_tibetan(document):
-    "Set the document language for Tibetan to English" 
+    "Set the document language for Tibetan to English"
 
     if document.language == "tibetan":
         document.language = "english"
-        i = find_token(document.header, "\\language", 0) 
-        if i != -1: 
-            document.header[i] = "\\language english" 
+        i = find_token(document.header, "\\language", 0)
+        if i != -1:
+            document.header[i] = "\\language english"
     j = 0
-    while j < len(document.body): 
+    while j < len(document.body):
         j = find_token(document.body, "\\lang tibetan", j)
         if j != -1:
             document.body[j] = document.body[j].replace("\\lang tibetan", 
"\\lang english")
@@ -4612,14 +4611,14 @@ def convert_chunks(document):
                 # there is no point continuing, as we will run into the same 
error again.
                 return
             this_chunk = "".join(document.body[i + 1:j])
-            
+
             # there may be empty lines between chunks
             # we just skip them.
             if not chunk_started:
                 if this_chunk != "":
                     # new chunk starts
                     chunk_started = True
-            
+
             if chunk_started:
                 contents.append(document.body[i + 1:j])
 
@@ -4666,7 +4665,7 @@ def convert_chunks(document):
         # the first par (separated from the options by a newline).
         # We collect such stuff to re-insert it later.
         postoptstuff = []
-        
+
         match = first_re.search(optarg)
         if match:
             optarg = match.groups()[0]
@@ -4806,7 +4805,7 @@ def revert_chunks(document):
         # replace old content with new content
         document.body[lstart : lend + 1] = newlines
         i = lstart + len(newlines)
-        
+
 
 ##
 # Conversion hub
diff --git 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_1_6-113c9a2.000.py" 
"b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_1_6.py"
index 2f8ebd24b8..2809eb208c 100644
--- 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\lyx_1_6-113c9a2.000.py"
+++ "b/D:\\LyXGit\\2.2.x\\lib\\lyx2lyx\\lyx_1_6.py"
@@ -424,7 +424,7 @@ def lyx2latex(document, lines):
             continue
         inert = ert_end >= curline
         content += lyxline2latex(document, lines[curline], inert)
-      
+
     return content
 
 
@@ -966,7 +966,7 @@ def revert_pdf_options(document):
 def remove_inzip_options(document):
     "Remove inzipName and embed options from the Graphics inset"
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset Graphics", i)
         if i == -1:
             return
@@ -994,7 +994,7 @@ def convert_inset_command(document):
             LatexCommand cmd
     """
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset LatexCommand", i)
         if i == -1:
             return
@@ -1033,7 +1033,7 @@ def revert_inset_command(document):
         will not be able to recognize. Not sure what to do about that.
     """
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset CommandInset", i)
         if i == -1:
             return
@@ -1256,7 +1256,7 @@ def revert_japanese_encoding(document):
 def revert_inset_info(document):
     'Replace info inset with its content'
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, '\\begin_inset Info', i)
         if i == -1:
             return
@@ -1737,7 +1737,7 @@ def convert_serbocroatian(document):
 def convert_framed_notes(document):
     "Convert framed notes to boxes. "
     i = 0
-    while 1:
+    while True:
         i = find_tokens(document.body, ["\\begin_inset Note Framed", 
"\\begin_inset Note Shaded"], i)
         if i == -1:
             return
@@ -1814,7 +1814,7 @@ def revert_colsep(document):
 def revert_framed_notes(document):
     "Revert framed boxes to notes. "
     i = 0
-    while 1:
+    while True:
         i = find_tokens(document.body, ["\\begin_inset Box Framed", 
"\\begin_inset Box Shaded"], i)
 
         if i == -1:
@@ -1932,7 +1932,7 @@ def revert_nocite_key(body, start, end):
 def revert_nocite(document):
     "Revert LatexCommand nocite to ERT"
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset CommandInset citation", i)
         if i == -1:
             return
@@ -2050,7 +2050,7 @@ def revert_serbianlatin(document):
 def revert_rotfloat(document):
     " Revert sideways custom floats. "
     i = 0
-    while 1:
+    while True:
         # whitespace intended (exclude \\begin_inset FloatList)
         i = find_token(document.body, "\\begin_inset Float ", i)
         if i == -1:
@@ -2113,7 +2113,7 @@ def revert_rotfloat(document):
 def revert_widesideways(document):
     " Revert wide sideways floats. "
     i = 0
-    while 1:
+    while True:
         # whitespace intended (exclude \\begin_inset FloatList)
         i = find_token(document.body, '\\begin_inset Float ', i)
         if i == -1:
@@ -2165,7 +2165,7 @@ def revert_widesideways(document):
 def revert_inset_embedding(document, type):
     ' Remove embed tag from certain type of insets'
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset %s" % type, i)
         if i == -1:
             return
@@ -2190,7 +2190,7 @@ def revert_external_embedding(document):
 def convert_subfig(document):
     " Convert subfigures to subfloats. "
     i = 0
-    while 1:
+    while True:
         addedLines = 0
         i = find_token(document.body, '\\begin_inset Graphics', i)
         if i == -1:
@@ -2230,7 +2230,7 @@ def convert_subfig(document):
 def revert_subfig(document):
     " Revert subfloats. "
     i = 0
-    while 1:
+    while True:
         # whitespace intended (exclude \\begin_inset FloatList)
         i = find_tokens(document.body, ['\\begin_inset Float ', '\\begin_inset 
Wrap'], i)
         if i == -1:
@@ -2734,7 +2734,7 @@ def convert_japanese_plain(document):
 def revert_pdfpages(document):
     ' Revert pdfpages external inset to ERT '
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset External", i)
         if i == -1:
             return
@@ -2836,7 +2836,7 @@ def revert_master(document):
 def revert_graphics_group(document):
     ' Revert group information from graphics insets '
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_inset Graphics", i)
         if i == -1:
             return
@@ -2866,7 +2866,7 @@ def update_apa_styles(document):
                     "Paragraph*":      "Paragraph",
                     "Subparagraph*":   "Subparagraph"}
     i = 0
-    while 1:
+    while True:
         i = find_token(document.body, "\\begin_layout", i)
         if i == -1:
             return

Reply via email to