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;
39 using std::ostringstream;
40 using std::stringstream;
44 // Hacks to allow the thing to link in the lyxlayout stuff
45 Debug::type const Debug::ANY = Debug::type(0);
48 void LyX::emergencyCleanup() {}
50 void handle_comment(Parser & p)
54 Token const & t = p.get_token();
55 if (t.cat() == catNewline)
59 //cerr << "comment: " << s << "\n";
64 string const trim(string const & a, char const * p)
71 string::size_type r = a.find_last_not_of(p);
72 string::size_type l = a.find_first_not_of(p);
74 // Is this the minimal test? (lgb)
75 if (r == string::npos && l == string::npos)
78 return a.substr(l, r - l + 1);
82 void split(string const & s, vector<string> & result, char delim)
84 //cerr << "split 1: '" << s << "'\n";
87 while (getline(is, t, delim))
89 //cerr << "split 2\n";
93 string join(vector<string> const & input, char const * delim)
96 for (size_t i = 0; i < input.size(); ++i) {
105 char const ** is_known(string const & str, char const ** what)
107 for ( ; *what; ++what)
115 // current stack of nested environments
116 vector<string> active_environments;
119 string active_environment()
121 return active_environments.empty() ? string() : active_environments.back();
125 int main(int argc, char * argv[])
128 cerr << "Usage: " << argv[0] << " <infile.tex>" << endl;
132 lyx::support::os::init(&argc, &argv);
133 lyx::support::setLyxPaths();
135 ifstream is(argv[1]);
140 LyXTextClass textclass = parse_preamble(p, ss);
141 active_environments.push_back("document");
142 Context context(true, textclass);
143 parse_text(p, ss, FLAG_END, true, context);
144 context.check_end_layout(ss);
145 ss << "\n\\end_document\n";