1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-1999 The LyX Team.
8 * This file is Copyright 1999
11 * ======================================================
17 #pragma implementation
20 #include "ImportNoweb.h"
22 #include "support/syscall.h"
23 #include "support/filetools.h"
24 #include "bufferlist.h"
27 extern BufferList bufferlist;
30 * Implementation the ImportNoweb methods.
33 Buffer * ImportNoweb::run()
36 string tmp = lyxrc->relyx_command + " -n -c " +
37 documentclass() + " -f " + file;
40 int result= one.startscript(Systemcalls::System, tmp);
42 string filename = file + ".lyx";
43 // File was generated without problems. Load it.
44 buf = bufferlist.loadLyXFile(filename);
49 // Provide the literate documentclass by parsing the file.
51 string ImportNoweb::documentclass()
53 string result = "literate-article"; // Default
55 FilePtr inputfile(file, FilePtr::read);
56 if (!inputfile()) return "nofile"; // Should not happen!
58 char buf[BUFSIZE], *p, *q;
60 while(!feof(inputfile())) {
61 (void)fgets(buf, BUFSIZE, inputfile());
62 if ((p = strstr(buf, "\\documentclass"))) {
63 while ((*p) && (*p != '{'))
66 while ((*q) && (*q != '}'))
70 result = "literate-" + result;