From 8f40d784c077e95f402c77b07f61c6f740ad67f1 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 3 Nov 2014 10:56:22 -0500 Subject: [PATCH] Fix bug 9300. We need manually to convert newlines to paragraph breaks. --- lib/lyx2lyx/lyx_2_1.py | 22 +++++++++++++++++++--- status.21x | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index 6b2a75f82c..e6d0bdca5b 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -4560,7 +4560,7 @@ def convert_chunks(document): contents.append(document.body[i + 1:j]) # look for potential chunk terminator - # on the last line of the chunk paragraph + # on the last line of the chunk paragraph if document.body[j - 1] == "@": break @@ -4573,7 +4573,7 @@ def convert_chunks(document): break file_pos = end = j + 1 - + # The last chunk should simply have an "@" in it # or at least end with "@" (can happen if @ is # preceded by a newline) @@ -4636,7 +4636,23 @@ def convert_chunks(document): # does not need to do that. did_one_par = False if postoptstuff: - newstuff.extend(postoptstuff) + # we need to replace newlines with new layouts + start_newline = -1 + started_text = False + for lno in range(0,len(postoptstuff)): + if postoptstuff[lno].startswith("\\begin_inset Newline newline"): + start_newline = lno + elif start_newline != -1: + if postoptstuff[lno].startswith("\\end_inset"): + # replace that bit, but only if we already have some text + # and we're not at the end except for a blank line + if started_text and \ + (lno != len(postoptstuff) - 2 or postoptstuff[-1] != ""): + newstuff.extend(['\\end_layout', '\n', '\\begin_layout Plain Layout', '\n']) + start_newline = -1 + started_text = True + else: + newstuff.extend([postoptstuff[lno]]) newstuff.append('\\end_layout') did_one_par = True for c in contents: diff --git a/status.21x b/status.21x index 78dfa5f5b9..114784414d 100644 --- a/status.21x +++ b/status.21x @@ -83,6 +83,8 @@ What's new - Fix import of Chunk layout with trailing empty paragraph (bug 9298). +- Fix import of chunk insets containing newlines (bug 9300). + * USER INTERFACE