]> git.lyx.org Git - lyx.git/commitdiff
tex2lyx improvments
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 27 Jul 2003 18:25:58 +0000 (18:25 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 27 Jul 2003 18:25:58 +0000 (18:25 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7392 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/ChangeLog
src/tex2lyx/text.C

index d02e58a939a45229b7b78e1519e52afea1c22f3f..b3cbeec33de4ca315047cc7cbbe2a0d871af91c8 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-27  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * 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  <leeming@lyx.org>
 
        * Makefile.am: remove unused graphics_link_files cruft.
 2003-07-27  Angus Leeming  <leeming@lyx.org>
 
        * Makefile.am: remove unused graphics_link_files cruft.
index 1f87652525e09796bc42a487487ca08fec8e74a2..7d15c4304cf0719012c495cd5e8f51a440065766 100644 (file)
@@ -80,7 +80,7 @@ void begin_inset(ostream & os, string const & name)
 
 void end_inset(ostream & os)
 {
 
 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 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");
                        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);
                }
        }
                        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('{', '}');
 
                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 ");
                        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);
                                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);
                                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");
                                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";
                                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") {
                }
 
                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 '['
                        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 << '\\' << t.cs();
                        os << p.getOpt();
                        os << p.getOpt();
-                       os << '{' << p.verbatim_item() << '}';
+                       os << '{' << p.verbatim_item() << "}\n";
                        end_inset(os);
                }
 
                        end_inset(os);
                }