From 11edc2b194e0f92a8eec6a81af38469521b17606 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sun, 27 Jul 2003 18:25:58 +0000 Subject: [PATCH] tex2lyx improvments git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7392 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/ChangeLog | 5 +++++ src/tex2lyx/text.C | 36 +++++++++++++++++------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/tex2lyx/ChangeLog b/src/tex2lyx/ChangeLog index d02e58a939..b3cbeec33d 100644 --- a/src/tex2lyx/ChangeLog +++ b/src/tex2lyx/ChangeLog @@ -1,3 +1,8 @@ +2003-07-27 Jean-Marc Lasgouttes + + * text.C (output_layout): fix handling of optional argument + (parse_text): small tweaks to make output format closer to lyx format + 2003-07-27 Angus Leeming * Makefile.am: remove unused graphics_link_files cruft. diff --git a/src/tex2lyx/text.C b/src/tex2lyx/text.C index 1f87652525..7d15c4304c 100644 --- a/src/tex2lyx/text.C +++ b/src/tex2lyx/text.C @@ -80,7 +80,7 @@ void begin_inset(ostream & os, string const & name) void end_inset(ostream & os) { - os << "\n\\end_inset\n\n"; + os << "\n\\end_inset \n\n"; } @@ -158,10 +158,12 @@ void output_layout(ostream & os, LyXLayout_ptr const & layout_ptr, string name = layout_ptr->name(); os << "\n\n\\layout " << name << "\n\n"; if (layout_ptr->optionalargs > 0) { - string opt = p.getOpt(); - if (opt.size()) { + string s; + if (p.next_token().character() == '[') { + p.get_token(); // eat '[' begin_inset(os, "OptArg\n"); - os << "collapsed true\n\n\\layout Standard\n\n" << opt; + os << "collapsed true\n\n\\layout Standard\n\n"; + parse_text(p, os, FLAG_BRACK_LAST, outer, textclass); end_inset(os); } } @@ -309,6 +311,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, else if (t.cs() == "begin") { string const name = p.getArg('{', '}'); + const bool is_starred = suffixIs(name, '*'); + string const unstarred_name = rtrim(name, "*"); active_environments.push_back(name); if (is_math_env(name)) { begin_inset(os, "Formula "); @@ -316,23 +320,16 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, parse_math(p, os, FLAG_END, MATH_MODE); os << "\\end{" << name << "}"; end_inset(os); - continue; - } - - if (name == "tabular") { + } else if (name == "tabular") { begin_inset(os, "Tabular "); handle_tabular(p, os, textclass); end_inset(os); - continue; - } - - bool is_starred = suffixIs(name, '*'); - string unstarred_name = rtrim(name, "*"); - if (textclass.floats().typeExist(unstarred_name)) { - string opts = p.getOpt(); + } else if (textclass.floats().typeExist(unstarred_name)) { begin_inset(os, "Float " + unstarred_name + "\n"); - if (opts.size()) - os << "placement " << opts << '\n'; + if (p.next_token().asInput() == "[") { + os << "placement " + << p.getArg('[', ']') << '\n'; + } os << "wide " << tostr(is_starred) << "\ncollapsed false\n\n" << "\\layout Standard\n"; @@ -383,7 +380,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, } else if (t.cs() == "item") { - p.skip_spaces(); + // should be done automatically by Parser::tokenize + //p.skip_spaces(); string s; if (p.next_token().character() == '[') { p.get_token(); // eat '[' @@ -527,7 +525,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, os << '\\' << t.cs(); os << p.getOpt(); os << p.getOpt(); - os << '{' << p.verbatim_item() << '}'; + os << '{' << p.verbatim_item() << "}\n"; end_inset(os); } -- 2.39.2