1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright (C) 1995 Matthias Ettrich
6 * Copyright (C) 1995-1999 The LyX Team.
8 * This file is Copyright (C) 1999
11 *======================================================
17 #pragma implementation
20 #include "ImportNoweb.h"
23 #include "filetools.h"
24 #include "bufferlist.h"
27 extern BufferList bufferlist;
29 // $Id: ImportNoweb.C,v 1.1 1999/09/27 18:44:36 larsbj Exp $
31 #if !defined(lint) && !defined(WITH_WARNINGS)
32 static char vcid[] = "$Id: ImportNoweb.C,v 1.1 1999/09/27 18:44:36 larsbj Exp $";
36 * Implementation the ImportNoweb methods.
39 Buffer * ImportNoweb::run()
42 LString tmp = lyxrc->relyx_command + " -n -c " +
43 documentclass() + " -f " + file;
46 int result= one.Startscript(Systemcalls::System, tmp);
48 LString filename = file + ".lyx";
49 // File was generated without problems. Load it.
50 buf = bufferlist.loadLyXFile(filename);
55 // Provide the literate documentclass by parsing the file.
57 LString ImportNoweb::documentclass()
59 LString result = "literate-article"; // Default
61 FilePtr inputfile(file, FilePtr::read);
62 if (!inputfile()) return "nofile"; // Should not happen!
64 char buf[BUFSIZE], *p, *q;
66 while(!feof(inputfile())) {
67 (void)fgets(buf, BUFSIZE, inputfile());
68 if ((p = strstr(buf, "\\documentclass"))) {
69 while ((*p) && (*p != '{'))
72 while ((*q) && (*q != '}'))
76 result = "literate-" + result;