From: Juergen Spitzmueller Date: Fri, 6 Dec 2013 10:57:33 +0000 (+0100) Subject: Improve beamer frame conversion: frame arguments that use multiple ERTs (one ERT... X-Git-Tag: 2.1.0rc1~356 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=0aaf2f2008b5aa8a5e64655fcc83cbe450a39486;p=features.git Improve beamer frame conversion: frame arguments that use multiple ERTs (one ERT inset per argument) are converted --- diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index 9816a1b884..f21c520e2f 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -2187,9 +2187,16 @@ def convert_beamerargs(document): # # Helper function for the frame conversion routines # +# FIXME: This method currently requires the arguments to be either +# * In one (whole) ERT each: [][arg3] +# * Altogether in one whole ERT: [][arg3] +# If individual arguments mix ERT and non-ERT or are splitted +# over several ERTs, the parsing fails. def convert_beamerframeargs(document, i, parbeg): ertend = i - if document.body[parbeg] == "\\begin_inset ERT": + while True: + if document.body[parbeg] != "\\begin_inset ERT": + return ertend ertend = find_end_of_inset(document.body, parbeg) if ertend == -1: document.warning("Malformed LyX document: missing ERT \\end_inset") @@ -2268,14 +2275,14 @@ def convert_beamerframeargs(document, i, parbeg): document.body[ertcont] = document.body[ertcont][:-1] # Convert to ArgInset document.body[parbeg] = "\\begin_inset Argument 3" + parbeg = ertend + 3 + continue return ertend def convert_againframe_args(document): " Converts beamer AgainFrame to new layout " - # FIXME: This currently only works if the arguments are in one single ERT - beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"] if document.textclass not in beamer_classes: return @@ -2292,7 +2299,10 @@ def convert_againframe_args(document): parbeg = parent[3] if i != -1: # Convert ERT arguments + # FIXME: See restrictions in convert_beamerframeargs method ertend = convert_beamerframeargs(document, i, parbeg) + if ertend == -1: + break i = j @@ -3784,10 +3794,10 @@ def convert_lyxframes(document): parbeg = parent[3] if i != -1: # Step I: Convert ERT arguments - # FIXME: This currently only works if the arguments are in one single ERT + # FIXME: See restrictions in convert_beamerframeargs method ertend = convert_beamerframeargs(document, i, parbeg) if ertend == -1: - continue + break # Step II: Now rename the layout and convert the title to an argument j = find_end_of_layout(document.body, i) document.body[j : j + 1] = ['\\end_layout', '', '\\end_inset', '', '\\end_layout']