-/** 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;
void LyX::emergencyCleanup() {}
-
void handle_comment(Parser & p)
{
string s;
}
-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) {
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;
}