diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 5d90fed629..e5b720997d 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1993,43 +1993,55 @@ void copy_file(FileName const & src, string dstname) } -/// Parse a NoWeb Chunk section. The initial "<<" is already parsed. -bool parse_noweb(Parser & p, ostream & os, Context & context) +/// Parse a literate Chunk section. The initial "<<" is already parsed. +bool parse_chunk(Parser & p, ostream & os, Context & context) { // check whether a chunk is possible here. - if (!context.new_layout_allowed || - !context.textclass.hasLayout(from_ascii("Chunk"))) { + if (!context.textclass.hasInsetLayout(from_ascii("Flex:Chunk"))) { return false; } p.pushPosition(); // read the parameters - Parser::Arg stuff = p.verbatimStuff(">>=", false); - if (!stuff.first) { + Parser::Arg const params = p.verbatimStuff(">>=\n", false); + if (!params.first) { p.popPosition(); return false; } - string chunk = "<<" + stuff.second + ">>=" - + p.verbatimStuff("\n").second + '\n'; - stuff = p.verbatimStuff("\n@"); - if (!stuff.first) { + Parser::Arg const code = p.verbatimStuff("\n@"); + if (!code.first) { p.popPosition(); return false; } - chunk += stuff.second + "\n@"; - string post_chunk = p.verbatimStuff("\n").second + '\n'; + string const post_chunk = p.verbatimStuff("\n").second + '\n'; if (post_chunk[0] != ' ' && post_chunk[0] != '\n') { p.popPosition(); return false; } - chunk += post_chunk; + // The last newline read is important for paragraph handling + p.putback(); + p.deparse(); - context.new_paragraph(os); - Context newcontext(true, context.textclass, - &context.textclass[from_ascii("Chunk")]); - output_ert(os, chunk, newcontext); + //cerr << "params=[" << params.second << "], code=[" << code.second << "]" <