On 13.01.19, Scott Kostyshak wrote: > On Fri, Jan 04, 2019 at 04:24:14PM -0500, Scott Kostyshak wrote: > > On Wed, Jan 24, 2018 at 05:39:11PM +0100, Günter Milde wrote: > > > commit a151b274bfbaae965a789f2250609c9404051cb9 > > > Author: Günter Milde <mi...@lyx.org> > > > Date: Wed Jan 24 17:38:19 2018 +0100 > > > > > > Fix lyx2lyx dash conversion and make it faster. > > > > This commit triggers a "Malformed LyX document" terminal warning when > > opening beamer.16.lyx (the beamer example file exported to 1.6.x > > format): > > > > $ lyx -e lyx16x beamer.lyx && lyx beamer.16.lyx > > Warning: Malformed LyX document: Can't find layout at line 5067 > > > > Günter, can you take a look?
> Günter, can you reproduce? Yes. Sorry for the delay, lyx2lyx is always tricky because of the many intermediate states. Now I could create a minimal example and explore the issue: There are two reasons for the "Malformed LyX document" warning: a) The reliance on well-formed layouts introduced in the abovementioned commit a151b274bf b) Malformed LyX documents generated by exporting beamer documents to 2.0 and 1.6 formats. The 2.0 and 1.6 exports create documents with "anonymous layouts", e.g. \begin_layout A frame without title. \end_layout while a well-formed LyX document requires a layout name like \begin_layout Standard A frame without title. \end_layout LyX itself seems to silently replace the "anonymous layout" with a Standard when parsing the file. I suggest to fix the issue b) and make the "find_containing_layout" function more robust by accepting nameless layouts (because this is what LyX itself does). The following patch solves the Warning when opening beamer.16.lyx Exec: git 'diff' 'parser_tools.py' 2>&1 Dir: /usr/local/src/lyx/lib/lyx2lyx/ diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index c53dbfa1ab..0de643440e 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -640,8 +640,8 @@ def get_containing_inset(lines, i): def get_containing_layout(lines, i): ''' Finds out what kind of layout line i is within. Returns a - list containing what follows \begin_layout on the line - on which the layout begins, plus the starting and ending line + list containing what follows \begin_layout on the layout start line + plus the starting and ending line and the start of the paragraph (after all params). I.e, returns: (layoutname, layoutstart, layoutend, startofcontent) Returns False on any kind of error. @@ -659,10 +659,9 @@ def get_containing_layout(lines, i): if endlay < i: return False - lay = get_value(lines, "\\begin_layout", stlay) - if lay == "": - # shouldn't happen - return False + layoutname= get_value(lines, "\\begin_layout", stlay) + if layoutname== "": + layoutname = "Standard" par_params = ["\\noindent", "\\indent", "\\indent-toggle", "\\leftindent", "\\start_of_appendix", "\\paragraph_spacing", "\\align", "\\labelwidthstring"] @@ -671,7 +670,7 @@ def get_containing_layout(lines, i): stpar += 1 if lines[stpar].split(' ', 1)[0] not in par_params: break - return (lay, stlay, endlay, stpar) + return (layoutname, stlay, endlay, stpar) def count_pars_in_inset(lines, i): But for some reason the ctests still fail: The following tests FAILED: 3515 - export/examples/beamer_lyx16 (Failed) 4792 - export/examples/de/beamer_lyx16 (Failed) 5299 - export/examples/fr/beamer_lyx16 (Failed) 5688 - export/examples/ja/beamer_lyx16 (Failed) 5690 - export/examples/ja/beamer_lyx22 (Failed) 5691 - export/examples/ja/beamer_lyx23 (Failed) Günter
minimal.lyx
Description: application/lyx
minimal.16.lyx
Description: application/lyx
minimal.20.lyx
Description: application/lyx
minimal.20.22.lyx
Description: application/lyx