]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/tex2lyx.C
Removed all redundant using directives from the source.
[lyx.git] / src / tex2lyx / tex2lyx.C
index ddfdd110836125d09764b948945aeb4163517d08..b357b03be8196ec16fe7d2c597c0b3afb4a06ba8 100644 (file)
@@ -1,10 +1,19 @@
-/** The .tex to .lyx converter
-    \author André Pönitz (2003)
+/**
+ * \file tex2lyx.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 // {[(
 
+#include <config.h>
+
 #include "tex2lyx.h"
+#include "context.h"
 
 #include "debug.h"
 #include "lyx_main.h"
 #include <sstream>
 #include <vector>
 
+using std::endl;
 using std::cout;
 using std::cerr;
-using std::endl;
 using std::getline;
-using std::istream;
+
 using std::ifstream;
 using std::istringstream;
-using std::ostream;
 using std::ostringstream;
 using std::stringstream;
 using std::string;
@@ -38,7 +46,6 @@ DebugStream lyxerr;
 
 void LyX::emergencyCleanup() {}
 
-
 void handle_comment(Parser & p)
 {
        string s;
@@ -114,34 +121,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) == "\\begin_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 +138,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;
 }