]> git.lyx.org Git - features.git/commitdiff
* text.C (parse_text): read environment from layout file too. Now,
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 28 Jul 2003 14:06:04 +0000 (14:06 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 28 Jul 2003 14:06:04 +0000 (14:06 +0000)
all layout entries are supported (but many hacks remain); note
that the nesting support is broken and will have to be completely
redone

* table.C (handle_tabular): make the output more similar to LyX
and fix a little

* text.C (output_layout): fix handling of optional argument
(parse_text): small tweaks to make output format closer to lyx
format; support \tableofcontents; fix/improve support for various
special characters

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7417 a592a061-630c-0410-9148-cb99ea01b6c8

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

index b3cbeec33de4ca315047cc7cbbe2a0d871af91c8..81c7d1614f210166c1f2a59497ef05affb3f5292 100644 (file)
@@ -1,7 +1,15 @@
-2003-07-27  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+2003-07-28  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * text.C (parse_text): read environment from layout file too. Now,
+       all layout entries are supported (but many hacks remain)
+
+       * table.C (handle_tabular): make the output more similar to LyX
+       and fix a little
 
        * text.C (output_layout): fix handling of optional argument
-       (parse_text): small tweaks to make output format closer to lyx format
+       (parse_text): small tweaks to make output format closer to lyx
+       format; support \tableofcontents; fix/improve support for various
+       special characters
 
 2003-07-27  Angus Leeming  <leeming@lyx.org>
 
index 773741005b91d1cd6f3f48b18dc403440fdf55e7..0d00c8e4fb397c5c3899206abdd86c75ad308097 100644 (file)
@@ -415,6 +415,9 @@ void handle_tabular(Parser & p, ostream & os,
 
                        } else {        
                                // FLAG_END is a hack, we need to read all of it
+                               cellinfo[row][col].leftline = colinfo[col].leftline;
+                               cellinfo[row][col].rightline = colinfo[col].rightline;
+                               cellinfo[row][col].align = colinfo[col].align;
                                cellinfo[row][col].content = parse_text(p, FLAG_END, false, textclass);
                        }
                }
@@ -435,21 +438,23 @@ void handle_tabular(Parser & p, ostream & os,
 
        //cerr << "// output what we have\n";
        // output what we have
-       os << "<lyxtabular version=\"3\" rows=\"" << rowinfo.size()
+       os << "\n<lyxtabular version=\"3\" rows=\"" << rowinfo.size()
                 << "\" columns=\"" << colinfo.size() << "\">\n"
                 << "<features>\n";
 
        //cerr << "// after header\n";
        for (size_t col = 0; col < colinfo.size(); ++col) {
-               os << "<column alignment=\"" << colinfo[col].align << "\"";
-               if (colinfo[col].rightline)
-                       os << " rightline=\"true\"";
+               os << "<column alignment=\""
+                  << verbose_align(colinfo[col].align) << "\"";
+               os << " valignment=\"top\"";
                if (colinfo[col].leftline)
                        os << " leftline=\"true\"";
+               if (colinfo[col].rightline)
+                       os << " rightline=\"true\"";
+               if (colinfo[col].width.size())
+                       os << " width=\"" << colinfo[col].width << "\"";
                if (colinfo[col].special.size())
                        os << " special=\"" << colinfo[col].special << "\"";
-               os << " valignment=\"top\"";
-               os << " width=\"" << colinfo[col].width << "\"";
                os << ">\n";
        }
        //cerr << "// after cols\n";
@@ -466,27 +471,28 @@ void handle_tabular(Parser & p, ostream & os,
                        os << "<cell";
                        if (cell.multi)
                                os << " multicolumn=\"" << cell.multi << "\"";
-                       if (cell.leftline)
-                               os << " leftline=\"true\"";
-                       if (cell.rightline)
-                               os << " rightline=\"true\"";
+                       os << " alignment=\"" << verbose_align(cell.align) 
+                          << "\""
+                          << " valignment=\"top\"";
                        if (cell.topline)
                                os << " topline=\"true\"";
                        if (cell.bottomline)
                                os << " bottomline=\"true\"";
+                       if (cell.leftline)
+                               os << " leftline=\"true\"";
+                       if (cell.rightline)
+                               os << " rightline=\"true\"";
                        //cerr << "\nrow: " << row << " col: " << col;
                        //if (cell.topline)
                        //      cerr << " topline=\"true\"";
                        //if (cell.bottomline)
                        //      cerr << " bottomline=\"true\"";
-                       os << " alignment=\"" << verbose_align(cell.align) << "\""
-                                << " valignment=\"top\""
-                                << " usebox=\"none\""
-                                << ">"
+                       os << " usebox=\"none\""
+                          << ">"
                           << "\n\\begin_inset Text"
                           << "\n\n\\layout Standard\n\n"
                           << cell.content
-                          << "\n\\end_inset\n\n"
+                          << "\n\\end_inset \n"
                           << "</cell>\n";
                }
                os << "</row>\n";
index 7d15c4304cf0719012c495cd5e8f51a440065766..22a0c570b0e7e486fab40aed978b77654efdc4fe 100644 (file)
@@ -103,7 +103,7 @@ void handle_ert(ostream & os, string const & s)
        os << "\nstatus Collapsed\n\n\\layout Standard\n\n";
        for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
                if (*it == '\\')
-                       os << "\n\\backslash\n";
+                       os << "\n\\backslash \n";
                else
                        os << *it;
        }
@@ -250,8 +250,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        if (t.character() == '~') {
                                if (active_environment() == "lyxcode")
                                        os << ' ';
-                               else
-                                       os << "\\SpecialChar ~\n";
+                               else 
+                                       os << "\\InsetSpace ~\n";
                        } else
                                os << t.character();
                }
@@ -288,11 +288,6 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                // control sequences
                //
 
-               else if (t.cs() == "ldots") {
-                       skip_braces(p);
-                       os << "\n\\SpecialChar \\ldots{}\n";
-               }
-
                else if (t.cs() == "(") {
                        begin_inset(os, "Formula");
                        os << " \\(";
@@ -340,25 +335,32 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                handle_par(os);
                                parse_text(p, os, FLAG_END, outer,
                                           textclass);
-                       } else if (name == "enumerate" || name == "itemize"
-                                       || name == "lyxlist") {
-                               size_t const n = active_environments.size();
-                               string const s = active_environments[n - 2];
-                               bool const deeper = s == "enumerate" || s == "itemize"
-                                       || s == "lyxlist";
-                               if (deeper)
-                                       os << "\n\\begin_deeper";
-                               os << "\n\\layout " << cap(name) << "\n\n";
-                               if (name == "lyxlist")
+                               // The single '=' is meant here.
+                       } else if ((layout_ptr = findLayout(textclass, t.cs())).get() &&
+                                  layout_ptr->isEnvironment()) {
+                               size_t const n = active_environments.size();
+                               string const s = active_environments[n - 2];
+                               bool const deeper = s == "enumerate" || s == "itemize"
+                                       || s == "lyxlist";
+                               if (deeper)
+                                       os << "\n\\begin_deeper";
+                               os << "\n\\layout " << layout_ptr->name() 
+                                  << "\n\n";
+                               switch (layout_ptr->latextype) {
+                               case  LATEX_LIST_ENVIRONMENT:
+                                       os << "\\labelwidthstring "
+                                          << p.verbatim_item() << '\n';
+                                       break;
+                               case  LATEX_BIB_ENVIRONMENT:
                                        p.verbatim_item(); // swallow next arg
+                                       break;
+                               default:
+                                       break;
+                               }
                                parse_text(p, os, FLAG_END, outer, textclass);
-                               if (deeper)
-                                       os << "\n\\end_deeper\n";
+                               if (deeper)
+                                       os << "\n\\end_deeper\n";
                                handle_par(os);
-                       } else if (name == "thebibliography") {
-                               p.verbatim_item(); // swallow next arg
-                               parse_text(p, os, FLAG_END, outer, textclass);
-                               os << "\n\\layout Bibliography\n\n";
                        } else {
                                handle_par(os);
                                parse_text(p, os, FLAG_END, outer, textclass);
@@ -388,7 +390,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                s = parse_text(p, FLAG_BRACK_LAST, outer, textclass);
                        }
                        handle_par(os);
-                       os << s << ' ';
+                       if (s.size())
+                               os << s << ' ';
                }
 
                else if (t.cs() == "def") {
@@ -463,8 +466,13 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                else if (t.cs() == "makeindex" || t.cs() == "maketitle")
                        skip_braces(p); // swallow this
 
-               else if (t.cs() == "tableofcontents")
+               else if (t.cs() == "tableofcontents") {
+                       begin_inset(os, "LatexCommand ");
+                       os << '\\' << t.cs() << "{}\n";
+                       end_inset(os);
                        skip_braces(p); // swallow this
+               }
+
 
                else if (t.cs() == "textrm") {
                        os << "\n\\family roman \n";
@@ -517,7 +525,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                else if (t.cs() == "bibitem") {
                        os << "\n\\layout Bibliography\n\\bibitem ";
                        os << p.getOpt();
-                       os << '{' << p.verbatim_item() << '}' << "\n\n";
+                       os << '{' << p.verbatim_item() << '}' << "\n";
                }
 
                else if (is_known(t.cs(), known_latex_commands)) {
@@ -553,6 +561,11 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        skip_braces(p); // eat {}
                }
 
+               else if (t.cs() == "ldots") {
+                       skip_braces(p);
+                       os << "\\SpecialChar \\ldots{}\n";
+               }
+
                else if (t.cs() == "lyxarrow") {
                        os << "\\SpecialChar \\menuseparator\n";
                        skip_braces(p);
@@ -563,11 +576,14 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        skip_braces(p);
                }
 
-               else if (t.cs() == "@") {
-                       os << "\\SpecialChar \\@";
-                       skip_braces(p);
+               else if (t.cs() == "@" && p.next_token().asInput() == ".") {
+                       os << "\\SpecialChar \\@.\n";
+                       p.get_token();
                }
 
+               else if (t.cs() == "-")
+                       os << "\\SpecialChar \\-\n";
+
                else if (t.cs() == "textasciitilde") {
                        os << '~';
                        skip_braces(p);
@@ -579,12 +595,13 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                }
 
                else if (t.cs() == "textbackslash") {
-                       os << "\n\\backslash\n";
+                       os << "\n\\backslash \n";
                        skip_braces(p);
                }
 
-               else if (t.cs() == "_" || t.cs() == "&" || t.cs() == "#" || t.cs() == "$"
-                           || t.cs() == "{" || t.cs() == "}" || t.cs() == "%")
+               else if (t.cs() == "_" || t.cs() == "&" || t.cs() == "#" 
+                           || t.cs() == "$" || t.cs() == "{" || t.cs() == "}" 
+                           || t.cs() == "%")
                        os << t.cs();
 
                else if (t.cs() == "char") {
@@ -626,11 +643,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                else if (t.cs() == "i" || t.cs() == "j")
                        os << "\\" << t.cs() << ' ';
 
-               else if (t.cs() == "-")
-                       os << "\\SpecialChar \\-\n";
-
                else if (t.cs() == "\\")
-                       os << "\n\\newline\n";
+                       os << "\n\\newline \n";
        
                else if (t.cs() == "input")
                        handle_ert(os, "\\input{" + p.verbatim_item() + "}\n");