From c31cb9fd98505d8f4c8564b0c3b75a7b410fb06c Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Fri, 1 Aug 2014 09:42:43 +0200 Subject: [PATCH] Improve parsing of ERT arguments in beamer block titles. Fixes: #9225 --- lib/lyx2lyx/lyx_2_1.py | 32 ++++++++++++++++++++++++-------- status.21x | 4 ++-- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index acb83c45d8..1a24675532 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -3062,14 +3062,30 @@ def convert_beamerblocks(document): if i != -1: if document.body[parbeg] == "\\begin_inset ERT": ertcontfirstline = parbeg + 5 - # Find the last ERT in this paragraph (which might also be the first) - lastertbeg = find_token_backwards(document.body, "\\begin_inset ERT", j) - if lastertbeg == -1: - document.warning("Last ERT not found!") - break - lastertend = find_end_of_inset(document.body, lastertbeg) - if lastertend == -1: - document.warning("End of last ERT not found!") + lastertbeg = -1 + lastertend = -1 + while True: + # Find the last ERT in this paragraph used for arguments + # (which might also be the first) + lastertbeg = find_token_backwards(document.body, "\\begin_inset ERT", j) + if lastertbeg == -1: + document.warning("Last ERT not found!") + break + lastertend = find_end_of_inset(document.body, lastertbeg) + if lastertend == -1: + document.warning("End of last ERT not found!") + break + # Is this ERT really used for an argument? + # Note: This will fail when non-argument ERTs actually use brackets + # (e.g. \pause{}) + regexp = re.compile(r'.*[>\]\}]', re.IGNORECASE) + cbracket = find_re(document.body, regexp, lastertbeg, lastertend) + if cbracket != -1: + break + if lastertbeg == parbeg: + break + j = lastertbeg - 1 + if lastertbeg == -1 or lastertend == -1: break ertcontlastline = lastertend - 3 while True: diff --git a/status.21x b/status.21x index e5b2cc38fc..02b4cd8334 100644 --- a/status.21x +++ b/status.21x @@ -61,8 +61,8 @@ What's new - Fix warning "Missing \use_indices" when converting from 1.6.x format or older. -- Fix conversion of multiple box overlay arguments in beamer when the - arguments use multiple ERTs (part of bug 9208). +- Fix several conversion problems of beamer box arguments when the + arguments use multiple ERTs (part of bug 9208, bug 9225). - Fix conversion of beamer overlay arguments when the module "beamer-resenumerate" is used (part of bug 9208). -- 2.39.5