3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
20 #include "lyxtextclass.h"
21 #include "support/path_defines.h"
22 #include "support/os.h"
37 using std::istringstream;
38 using std::ostringstream;
39 using std::stringstream;
43 // Hacks to allow the thing to link in the lyxlayout stuff
44 LyXErr lyxerr(std::cerr.rdbuf());
46 void LyX::emergencyCleanup() {}
48 void handle_comment(Parser & p)
52 Token const & t = p.get_token();
53 if (t.cat() == catNewline)
57 //cerr << "comment: " << s << "\n";
62 string const trim(string const & a, char const * p)
69 string::size_type r = a.find_last_not_of(p);
70 string::size_type l = a.find_first_not_of(p);
72 // Is this the minimal test? (lgb)
73 if (r == string::npos && l == string::npos)
76 return a.substr(l, r - l + 1);
80 void split(string const & s, vector<string> & result, char delim)
82 //cerr << "split 1: '" << s << "'\n";
85 while (getline(is, t, delim))
87 //cerr << "split 2\n";
91 string join(vector<string> const & input, char const * delim)
94 for (size_t i = 0; i < input.size(); ++i) {
103 char const ** is_known(string const & str, char const ** what)
105 for ( ; *what; ++what)
113 // current stack of nested environments
114 vector<string> active_environments;
117 string active_environment()
119 return active_environments.empty() ? string() : active_environments.back();
123 int main(int argc, char * argv[])
126 cerr << "Usage: " << argv[0] << " <infile.tex>" << endl;
130 lyx::support::os::init(&argc, &argv);
131 lyx::support::setLyxPaths();
133 ifstream is(argv[1]);
138 LyXTextClass textclass = parse_preamble(p, ss);
139 active_environments.push_back("document");
140 Context context(true, textclass);
141 parse_text(p, ss, FLAG_END, true, context);
142 context.check_end_layout(ss);
143 ss << "\n\\end_document\n";