1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-2000 The LyX Team.
8 * This file is Copyright 1999
11 * ======================================================
17 #pragma implementation
23 #include "ImportNoweb.h"
25 #include "support/syscall.h"
26 #include "bufferlist.h"
31 extern BufferList bufferlist;
34 * Implementation the ImportNoweb methods.
37 Buffer * ImportNoweb::run()
40 string tmp = lyxrc.relyx_command + " -n -c " +
41 documentclass() + " -f " + file;
44 int result= one.startscript(Systemcalls::System, tmp);
46 string filename = file + ".lyx";
47 // File was generated without problems. Load it.
48 buf = bufferlist.loadLyXFile(filename);
54 // Provide the literate documentclass by parsing the file.
55 string ImportNoweb::documentclass()
57 string result = "literate-article"; // Default
59 ifstream ifs(file.c_str());
61 if (!ifs) return "nofile"; // Should not happen!
63 while (getline(ifs, line)) {
64 string::size_type p = line.find("\\documentclass");
65 if (p != string::npos) {
66 p = line.find('{', p);
67 string::size_type q = line.find('}', p);
68 result = "literate-" + line.substr(p + 1, q - p - 1);