X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftex2lyx%2Ftext.cpp;h=2c212a425fffbc7afc57b8171e0a591c94baf0fa;hb=9b530e59c2b74828f3a68f3bb7ee3dee0365cdc0;hp=2206e003705373857181791318a9a8d9c6ff7fa5;hpb=1b32a0502e9206813b6b41365848673d8ac70b03;p=lyx.git diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 2206e00370..2c212a425f 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -112,10 +112,10 @@ string parse_text_snippet(Parser & p, unsigned flags, const bool outer, char const * const known_ref_commands[] = { "ref", "pageref", "vref", - "vpageref", "prettyref", "eqref", 0 }; + "vpageref", "prettyref", "nameref", "eqref", 0 }; char const * const known_coded_ref_commands[] = { "ref", "pageref", "vref", - "vpageref", "formatted", "eqref", 0 }; + "vpageref", "formatted", "nameref", "eqref", 0 }; char const * const known_refstyle_commands[] = { "algref", "chapref", "corref", "eqref", "enuref", "figref", "fnref", "lemref", "parref", "partref", "propref", @@ -935,9 +935,8 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags, width_unit = "in"; width_special = "width"; } else if (latex_width.empty() && outer_type == "framebox") { - outer_type == "fbox"; - width_value = "-999"; - width_unit = "col%"; + width_value.clear(); + width_unit.clear(); width_special = "none"; } if (use_ert) { @@ -1038,7 +1037,7 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags, else os << "use_makebox " << (inner_type == "makebox") << '\n'; if (outer_type == "fbox" || outer_type == "mbox") - os << "width \"-999col%\"\n"; + os << "width \"\"\n"; else os << "width \"" << width_value << width_unit << "\"\n"; os << "special \"" << width_special << "\"\n"; @@ -1526,6 +1525,37 @@ void parse_environment(Parser & p, ostream & os, bool outer, preamble.registerAutomaticallyLoadedPackage("color"); } + else if (name == "btSect") { + eat_whitespace(p, os, parent_context, false); + parent_context.check_layout(os); + begin_command_inset(os, "bibtex", "bibtex"); + string bibstyle = "plain"; + if (p.hasOpt()) { + bibstyle = p.getArg('[', ']'); + p.skip_spaces(true); + } + string const bibfile = p.getArg('{', '}'); + eat_whitespace(p, os, parent_context, false); + Token t = p.get_token(); + if (t.asInput() == "\\btPrintCited") { + p.skip_spaces(true); + os << "btprint " << '"' << "btPrintCited" << '"' << "\n"; + } + if (t.asInput() == "\\btPrintNotCited") { + p.skip_spaces(true); + os << "btprint " << '"' << "btPrintNotCited" << '"' << "\n"; + } + if (t.asInput() == "\\btPrintAll") { + p.skip_spaces(true); + os << "btprint " << '"' << "btPrintAll" << '"' << "\n"; + } + os << "bibfiles " << '"' << bibfile << '"' << "\n"; + os << "options " << '"' << bibstyle << '"' << "\n"; + parse_text_in_inset(p, os, FLAG_END, outer, parent_context); + end_inset(os); + p.skip_spaces(); + } + else if (name == "framed" || name == "shaded") { eat_whitespace(p, os, parent_context, false); parse_outer_box(p, os, FLAG_END, outer, parent_context, name, ""); @@ -1600,24 +1630,13 @@ void parse_environment(Parser & p, ostream & os, bool outer, if (last_env == name) { // we need to output a separator since LyX would export // the two environments as one otherwise (bug 5716) - docstring const sep = from_ascii("--Separator--"); TeX2LyXDocClass const & textclass(parent_context.textclass); - if (textclass.hasLayout(sep)) { - Context newcontext(parent_context); - newcontext.layout = &(textclass[sep]); - newcontext.check_layout(os); - newcontext.check_end_layout(os); - } else { - parent_context.check_layout(os); - begin_inset(os, "Note Note\n"); - os << "status closed\n"; - Context newcontext(true, textclass, - &(textclass.defaultLayout())); - newcontext.check_layout(os); - newcontext.check_end_layout(os); - end_inset(os); - parent_context.check_end_layout(os); - } + Context newcontext(true, textclass, + &(textclass.defaultLayout())); + newcontext.check_layout(os); + begin_inset(os, "Separator plain\n"); + end_inset(os); + newcontext.check_end_layout(os); } switch (context.layout->latextype) { case LATEX_LIST_ENVIRONMENT: @@ -1994,43 +2013,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 << "]" <labeltype != LABEL_MANUAL) { - // LyX does not support \item[\mybullet] - // in itemize environments + // handle option of itemize item + begin_inset(os, "Argument item:1\n"); + os << "status open\n"; + os << "\n\\begin_layout Plain Layout\n"; Parser p2(s + ']'); os << parse_text_snippet(p2, FLAG_BRACK_LAST, outer, context); + // we must not use context.check_end_layout(os) + // because that would close the outer itemize layout + os << "\n\\end_layout\n"; + end_inset(os); + eat_whitespace(p, os, context, false); } else if (!s.empty()) { // LyX adds braces around the argument, // so we need to remove them here. @@ -2617,8 +2655,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, } else { Parser p2(s + ']'); os << parse_text_snippet(p2, - FLAG_BRACK_LAST, - outer, context); + FLAG_BRACK_LAST, outer, context); } // The space is needed to separate the // item from the rest of the sentence. @@ -3930,8 +3967,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, string const absfigname = changeExtension(abstexname, ".fig"); fix_child_filename(filename); - string const lyxname = - changeExtension(filename, ".lyx"); + string const lyxname = changeExtension(filename, + roundtripMode() ? ".lyx.lyx" : ".lyx"); string const abslyxname = makeAbsPath( lyxname, getParentFilePath(false)).absFileName(); bool xfig = false;