From ede754039d15029260047efcc2fe3ccd4f633b3b Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 8 May 2014 19:52:01 +0200 Subject: [PATCH] Beamer block conversion: consider ERT arguments with leading/trailing blanks Should also go to branch. --- lib/lyx2lyx/lyx_2_1.py | 20 ++++++++++---------- status.21x | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index d327d87a36..20d87badd0 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -2989,18 +2989,18 @@ def convert_beamerblocks(document): break ertcontlastline = lastertend - 3 while True: - if document.body[ertcontfirstline].startswith("<"): + if document.body[ertcontfirstline].lstrip().startswith("<"): # This is an overlay specification # strip off the < - document.body[ertcontfirstline] = document.body[ertcontfirstline][1:] - if document.body[ertcontlastline].endswith(">"): + document.body[ertcontfirstline] = document.body[ertcontfirstline].lstrip()[1:] + if document.body[ertcontlastline].rstrip().endswith(">"): # strip off the > - document.body[ertcontlastline] = document.body[ertcontlastline][:-1] + document.body[ertcontlastline] = document.body[ertcontlastline].rstrip()[:-1] # Convert to ArgInset document.body[parbeg] = "\\begin_inset Argument 1" - elif document.body[ertcontlastline].endswith("}"): + elif document.body[ertcontlastline].rstrip().endswith("}"): # strip off the } - document.body[ertcontlastline] = document.body[ertcontlastline][:-1] + document.body[ertcontlastline] = document.body[ertcontlastline].rstrip()[:-1] # divide the args ertcontdivline = ertcontfirstline tok = document.body[ertcontdivline].find('>{') @@ -3025,12 +3025,12 @@ def convert_beamerblocks(document): document.body[ertcontdivline][tok + 2:]] # Convert to ArgInset document.body[parbeg] = "\\begin_inset Argument 1" - elif document.body[ertcontfirstline].startswith("{"): + elif document.body[ertcontfirstline].lstrip().startswith("{"): # This is the block title - if document.body[ertcontlastline].endswith("}"): + if document.body[ertcontlastline].rstrip().endswith("}"): # strip off the braces - document.body[ertcontfirstline] = document.body[ertcontfirstline][1:] - document.body[ertcontlastline] = document.body[ertcontlastline][:-1] + document.body[ertcontfirstline] = document.body[ertcontfirstline].lstrip()[1:] + document.body[ertcontlastline] = document.body[ertcontlastline].rstrip()[:-1] if ertcontfirstline < ertcontlastline: # Multiline ERT. Might contain TeX code. Embrace in ERT. document.body[parend : parend + 1] = [ diff --git a/status.21x b/status.21x index 0f05bc7ad3..07e3e4e9c3 100644 --- a/status.21x +++ b/status.21x @@ -67,6 +67,8 @@ What's new - Fix conversion of beamer block titles ending with non-ERT insets to 2.1 format. +- Fix conversion of beamer blocks with preceding or trailing blanks. + - Add \justification parameter when converting to 2.1 format (avoids when converting back to 2.0 format).