]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/tex2lyx.C
* funcrequest.C: initialize button_ member
[lyx.git] / src / tex2lyx / tex2lyx.C
index 9412dfec02410764b00a3186c848d9fd90fc6599..a2a60e2370fdbdb2a89415f69d13a0d7d595bb98 100644 (file)
@@ -5,6 +5,7 @@
 // {[(
 
 #include "tex2lyx.h"
+#include "context.h"
 
 #include "debug.h"
 #include "lyx_main.h"
@@ -38,7 +39,6 @@ DebugStream lyxerr;
 
 void LyX::emergencyCleanup() {}
 
-
 void handle_comment(Parser & p)
 {
        string s;
@@ -114,34 +114,6 @@ string active_environment()
 }
 
 
-void clean_layouts(istream & is, ostream & os)
-{
-       string last;
-       string line;
-       bool eating = false;
-       while (getline(is, line)) {
-               string tline = trim(line, " ");
-               if (line.substr(0, 8) == "\\layout ") {
-                       //cerr << "layout: " << line << "\n";
-                       last = line;
-                       eating = true;
-               } else if (eating && tline.empty()) {
-                       //cerr << "eat empty line\n"; 
-               } else if (line.substr(0, 13) == "\\begin_deeper") {
-                       os << line << "\n";
-               } else {
-                       // ordinary line  
-                       //cerr << "ordinary line\n"; 
-                       if (eating) {
-                               eating = false;
-                               os << last << "\n\n";
-                       }
-                       os << line << "\n";
-               }
-       }
-}
-
-
 int main(int argc, char * argv[])
 {
        if (argc <= 1) {
@@ -159,12 +131,13 @@ int main(int argc, char * argv[])
        stringstream ss;
        LyXTextClass textclass = parse_preamble(p, ss);
        active_environments.push_back("document");
-       parse_text(p, ss, FLAG_END, true, textclass);
-       ss << "\n\\the_end\n";
+       Context context(true, textclass);
+       parse_text(p, ss, FLAG_END, true, context);
+       context.check_end_layout(ss);
+       ss << "\n\\end_document\n";
 
        ss.seekg(0);
-       clean_layouts(ss, cout);
-
+       cout << ss.str();
        return 0;
 }