]> git.lyx.org Git - features.git/commitdiff
Fix beamer block conversion when arguments are in multiple ERTS.
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 27 Jul 2014 09:30:25 +0000 (11:30 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 27 Jul 2014 09:30:25 +0000 (11:30 +0200)
Fixes second part of #9208.

lib/lyx2lyx/lyx_2_1.py

index ae4c39069f390615a2663c1807c893b7e2729c4b..acb83c45d83885198f0d22802060620c7a786eee 100644 (file)
@@ -3090,7 +3090,7 @@ def convert_beamerblocks(document):
                                 tok = document.body[ertcontdivline].find('>{')
                                 if tok == -1:
                                     regexp = re.compile(r'.*>\{', re.IGNORECASE)
-                                    ertcontdivline = find_re(document.body, regexp, ertcontfirstline, ertcontlastline)
+                                    ertcontdivline = find_re(document.body, regexp, ertcontfirstline, lastertend)
                                     tok = document.body[ertcontdivline].find('>{')
                                 if tok != -1:
                                     if ertcontfirstline < ertcontlastline:
@@ -3112,30 +3112,30 @@ def convert_beamerblocks(document):
                                     tok = document.body[ertcontdivline].find('>')
                                     if tok == -1:
                                         regexp = re.compile(r'.*>', re.IGNORECASE)
-                                        ertcontdivline = find_re(document.body, regexp, ertcontfirstline, ertcontlastline)
+                                        ertcontdivline = find_re(document.body, regexp, ertcontfirstline, lastertend)
                                         tok = document.body[ertcontdivline].find('>')
-                                        if tok != -1:
-                                            tokk = document.body[ertcontdivline].find('{')
-                                            if tokk == -1:
-                                                regexp = re.compile(r'.*\{', re.IGNORECASE)
-                                                ertcontdivlinetwo = find_re(document.body, regexp, ertcontfirstline, ertcontlastline)
-                                                tokk = document.body[ertcontdivlinetwo].find('{')
-                                                if tokk != -1:
-                                                    if ertcontfirstline < ertcontlastline:
-                                                        # Multiline ERT. Might contain TeX code.  Embrace in ERT.
-                                                        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_inset', '', '', '\\begin_inset Argument 2',
-                                                                                            'status collapsed', '', '\\begin_layout Plain Layout',
-                                                                                            '\\begin_inset ERT', '', 'status open' '', '\\begin_layout Plain Layout',
-                                                                                            document.body[ertcontdivlinetwo][tokk + 1:]]
-                                                    else:
-                                                        document.body[ertcontdivline : ertcontdivlinetwo + 1] = [document.body[ertcontdivline][:tok],
-                                                                                            '\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 2',
-                                                                                            'status collapsed', '', '\\begin_layout Plain Layout',
-                                                                                            document.body[ertcontdivlinetwo][tokk + 1:]]
+                                    if tok != -1:
+                                        tokk = document.body[ertcontdivline].find('{')
+                                        if tokk == -1:
+                                            regexp = re.compile(r'.*\{', re.IGNORECASE)
+                                            ertcontdivlinetwo = find_re(document.body, regexp, ertcontfirstline, lastertend)
+                                            tokk = document.body[ertcontdivlinetwo].find('{')
+                                        if tokk != -1:
+                                            if ertcontfirstline < ertcontlastline:
+                                                # Multiline ERT. Might contain TeX code.  Embrace in ERT.
+                                                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_inset', '', '', '\\begin_inset Argument 2',
+                                                                                    'status collapsed', '', '\\begin_layout Plain Layout',
+                                                                                    '\\begin_inset ERT', '', 'status open' '', '\\begin_layout Plain Layout',
+                                                                                    document.body[ertcontdivlinetwo][tokk + 1:]]
+                                            else:
+                                                document.body[ertcontdivline : ertcontdivlinetwo + 1] = [document.body[ertcontdivline][:tok],
+                                                                                    '\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 2',
+                                                                                    'status collapsed', '', '\\begin_layout Plain Layout',
+                                                                                    document.body[ertcontdivlinetwo][tokk + 1:]]
                                 # Convert to ArgInset
                                 if ertcontfirstline < ertcontlastline:
                                     # Multiline ERT. Might contain TeX code.  Embrace in ERT.
@@ -3171,7 +3171,7 @@ def convert_beamerblocks(document):
                                 tok = document.body[ertcontdivline].find('}<')
                                 if tok == -1:
                                     regexp = re.compile(r'.*\}<', re.IGNORECASE)
-                                    ertcontdivline = find_re(document.body, regexp, ertcontfirstline, ertcontlastline)
+                                    ertcontdivline = find_re(document.body, regexp, ertcontfirstline, lastertend)
                                     tok = document.body[ertcontdivline].find('}<')
                                 if tok != -1:
                                     if ertcontfirstline < ertcontlastline:
@@ -3193,13 +3193,13 @@ def convert_beamerblocks(document):
                                     tok = document.body[ertcontdivline].find('}')
                                     if tok == -1:
                                         regexp = re.compile(r'.*\}', re.IGNORECASE)
-                                        ertcontdivline = find_re(document.body, regexp, ertcontfirstline, ertcontlastline)
+                                        ertcontdivline = find_re(document.body, regexp, ertcontfirstline, lastertend)
                                         tok = document.body[ertcontdivline].find('}')
                                         if tok != -1:
                                             tokk = document.body[ertcontdivline].find('<')
                                             if tokk == -1:
                                                 regexp = re.compile(r'.*<', re.IGNORECASE)
-                                                ertcontdivlinetwo = find_re(document.body, regexp, ertcontfirstline, ertcontlastline)
+                                                ertcontdivlinetwo = find_re(document.body, regexp, ertcontfirstline, lastertend)
                                                 tokk = document.body[ertcontdivlinetwo].find('<')
                                                 if tokk != -1:
                                                     if ertcontfirstline < ertcontlastline: