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 Debug::type const Debug::ANY = Debug::type(0);
47 void LyX::emergencyCleanup() {}
49 void handle_comment(Parser & p)
53 Token const & t = p.get_token();
54 if (t.cat() == catNewline)
58 //cerr << "comment: " << s << "\n";
63 string const trim(string const & a, char const * p)
70 string::size_type r = a.find_last_not_of(p);
71 string::size_type l = a.find_first_not_of(p);
73 // Is this the minimal test? (lgb)
74 if (r == string::npos && l == string::npos)
77 return a.substr(l, r - l + 1);
81 void split(string const & s, vector<string> & result, char delim)
83 //cerr << "split 1: '" << s << "'\n";
86 while (getline(is, t, delim))
88 //cerr << "split 2\n";
92 string join(vector<string> const & input, char const * delim)
95 for (size_t i = 0; i < input.size(); ++i) {
104 char const ** is_known(string const & str, char const ** what)
106 for ( ; *what; ++what)
114 // current stack of nested environments
115 vector<string> active_environments;
118 string active_environment()
120 return active_environments.empty() ? string() : active_environments.back();
124 int main(int argc, char * argv[])
127 cerr << "Usage: " << argv[0] << " <infile.tex>" << endl;
131 lyx::support::os::init(&argc, &argv);
132 lyx::support::setLyxPaths();
134 ifstream is(argv[1]);
139 LyXTextClass textclass = parse_preamble(p, ss);
140 active_environments.push_back("document");
141 Context context(true, textclass);
142 parse_text(p, ss, FLAG_END, true, context);
143 context.check_end_layout(ss);
144 ss << "\n\\end_document\n";