Hi, since I haven't found a way out of jail (read firewall) and living (read coding) thanks to others generosity (Thanks Kayvan for your daily cvs snapshots). Here follows a patch for docbook, this fixes some small glitches with included files in linuxdoc and docbook. I have been able to insert files to the fifth level (I haven't tried more), and using this in a daily basis. Another fix is XML compatibility for docbook. Now all the docbook output should be XML compatible (that all opening tags have a corresponding close tag). Tell me if you have any problems applying this patch. One note about this patch, I have added a dependency between src/LaTeXFeatures.C and src/support/filetools.[Ch]. That is, LaTeXFeatures.C calls some functions from filetools. Where do I add this dependency? Note to Lars: I intend to clean the docbook and linuxdoc generation code for 1.2. There places that really need it. -- José
diff -ur lyx-1.1.6cvs/ChangeLog lyx-1.1.6cvs.new/ChangeLog --- lyx-1.1.6cvs/ChangeLog Fri Oct 27 09:19:37 2000 +++ lyx-1.1.6cvs.new/ChangeLog Mon Nov 13 14:16:55 2000 @@ -1,3 +1,34 @@ +2000-11-13 José Abílio Matos <[EMAIL PROTECTED]> + + * lib/layouts/docbook-book.layout + * lib/layouts/docbook.layout + * lib/layouts/linuxdoc.layout: No need for "dummy" paragraphs, now + those paragraphs are expresse as SGML comments <!-- -->. + + * src/LaTeXFeatures.h + * src/LaTeXFeatures.C (getIncludedFiles): takes a filename as + parameter, this allows to express all the include files as relative + paths to the master buffer. The verbatim insert works as the other + include file modes. + + * src/buffer.C (sgmlOpenTag) (sgmlCloseTag): don't write if latexname + is a SGML comment. + (MakeLinuxdocFile) (MakeDocBookFile): included files are relative + to master path. + (MakeDocBookFile): top_element is always written. Some clean up, as + sgmlOpenTag() and sgmlCloseTag() take care of the SGML comment case. + + * src/insets/insetinclude.C (Linuxdoc): Added verbatim file fix. + (DocBook) added close tag to inlinegraphics trick for verbatim. Now + a reference is written instead of the name. + (Validate): use the relative path for the filename. + + * src/insets/insetlabel.C (DocBook): write end tag, for XML compatibility. + + * src/support/filetools.h + * src/support/filetools.C (IsSGMLFilename): added. + (BasePath): added. + 2000-11-13 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * src/converter.C: add "using" directive. diff -ur lyx-1.1.6cvs/lib/layouts/docbook-book.layout lyx-1.1.6cvs.new/lib/layouts/docbook-book.layout --- lyx-1.1.6cvs/lib/layouts/docbook-book.layout Fri Sep 29 12:12:11 2000 +++ lyx-1.1.6cvs.new/lib/layouts/docbook-book.layout Mon Nov 13 08:16:25 2000 @@ -163,6 +163,7 @@ # SGML style definition Style SGML CopyStyle LaTeX + LatexName "!-- --" End # There are no chapters or parts in an docbook article. diff -ur lyx-1.1.6cvs/lib/layouts/docbook.layout lyx-1.1.6cvs.new/lib/layouts/docbook.layout --- lyx-1.1.6cvs/lib/layouts/docbook.layout Sat Oct 2 15:01:02 1999 +++ lyx-1.1.6cvs.new/lib/layouts/docbook.layout Mon Nov 13 08:16:25 2000 @@ -153,6 +153,7 @@ # SGML style definition Style SGML CopyStyle LaTeX + LatexName "!-- --" End # There are no chapters or parts in an docbook article. diff -ur lyx-1.1.6cvs/lib/layouts/linuxdoc.layout lyx-1.1.6cvs.new/lib/layouts/linuxdoc.layout --- lyx-1.1.6cvs/lib/layouts/linuxdoc.layout Fri Sep 29 12:12:11 2000 +++ lyx-1.1.6cvs.new/lib/layouts/linuxdoc.layout Mon Nov 13 08:16:25 2000 @@ -368,7 +368,7 @@ Style SGML Margin Static LatexType Paragraph - LatexName dummy + LatexName "!-- --" NewLine 0 ParIndent MM ParSkip 0.4 diff -ur lyx-1.1.6cvs/src/LaTeXFeatures.C lyx-1.1.6cvs.new/src/LaTeXFeatures.C --- lyx-1.1.6cvs/src/LaTeXFeatures.C Wed Oct 11 22:06:39 2000 +++ lyx-1.1.6cvs.new/src/LaTeXFeatures.C Mon Nov 13 08:16:25 2000 @@ -22,7 +22,7 @@ #include "LaTeXFeatures.h" #include "bufferparams.h" #include "layout.h" - +#include "support/filetools.h" using std::endl; LaTeXFeatures::LaTeXFeatures(BufferParams const & p, LyXTextClass::size_type n) @@ -338,14 +338,17 @@ } -string const LaTeXFeatures::getIncludedFiles() +string const LaTeXFeatures::getIncludedFiles(string const fname) const { string sgmlpreamble; + string basename = BasePath(fname); + FileMap::const_iterator end = IncludedFiles.end(); for (FileMap::const_iterator fi = IncludedFiles.begin(); fi != end; ++fi) - sgmlpreamble += "\n<!entity " + fi->first - + " system \"" + fi->second + "\">"; + sgmlpreamble += "\n<!ENTITY " + fi->first + + (IsSGMLFilename(fi->second) ? " SYSTEM \"" : " \"" ) + + MakeRelPath(fi->second,basename) + "\">"; return sgmlpreamble; } diff -ur lyx-1.1.6cvs/src/LaTeXFeatures.h lyx-1.1.6cvs.new/src/LaTeXFeatures.h --- lyx-1.1.6cvs/src/LaTeXFeatures.h Wed Sep 27 18:07:33 2000 +++ lyx-1.1.6cvs.new/src/LaTeXFeatures.h Mon Nov 13 08:16:25 2000 @@ -42,7 +42,7 @@ /// The definitions needed by the document's textclass string const getTClassPreamble(); /// - string const getIncludedFiles(); + string const getIncludedFiles(string const fname) const; /// void showStruct(); diff -ur lyx-1.1.6cvs/src/buffer.C lyx-1.1.6cvs.new/src/buffer.C --- lyx-1.1.6cvs/src/buffer.C Wed Nov 8 09:39:43 2000 +++ lyx-1.1.6cvs.new/src/buffer.C Mon Nov 13 08:35:47 2000 @@ -2336,14 +2336,16 @@ void Buffer::sgmlOpenTag(ostream & os, int depth, string const & latexname) const { - os << string(depth, ' ') << "<" << latexname << ">\n"; + if (latexname != "!-- --") + os << string(depth, ' ') << "<" << latexname << ">\n"; } void Buffer::sgmlCloseTag(ostream & os, int depth, string const & latexname) const { - os << string(depth, ' ') << "</" << latexname << ">\n"; + if (latexname != "!-- --") + os << string(depth, ' ') << "</" << latexname << ">\n"; } @@ -2380,7 +2382,7 @@ texrow.reset(); if (!body_only) { - string sgml_includedfiles=features.getIncludedFiles(); + string sgml_includedfiles=features.getIncludedFiles(fname); if (params.preamble.empty() && sgml_includedfiles.empty()) { ofs << "<!doctype linuxdoc system>\n\n"; @@ -3000,7 +3002,7 @@ texrow.reset(); if (!only_body) { - string sgml_includedfiles=features.getIncludedFiles(); + string sgml_includedfiles=features.getIncludedFiles(fname); ofs << "<!doctype " << top_element << " public \"-//OASIS//DTD DocBook V3.1//EN\""; @@ -3010,15 +3012,15 @@ else ofs << "\n [ " << params.preamble << sgml_includedfiles << " \n]>\n\n"; + } - if (params.options.empty()) - sgmlOpenTag(ofs, 0, top_element); - else { - string top = top_element; - top += " "; - top += params.options; - sgmlOpenTag(ofs, 0, top); - } + if (params.options.empty()) + sgmlOpenTag(ofs, 0, top_element); + else { + string top = top_element; + top += " "; + top += params.options; + sgmlOpenTag(ofs, 0, top); } ofs << "<!-- DocBook file was created by " << LYX_DOCVERSION @@ -3069,9 +3071,7 @@ // Write opening SGML tags. switch (style.latextype) { case LATEX_PARAGRAPH: - if (style.latexname() != "dummy") - sgmlOpenTag(ofs, depth+command_depth, - style.latexname()); + sgmlOpenTag(ofs, depth+command_depth, style.latexname()); break; case LATEX_COMMAND: @@ -3124,7 +3124,8 @@ sgmlOpenTag(ofs, depth + command_depth, command_name); item_name = "title"; - sgmlOpenTag(ofs, depth + 1 + command_depth, item_name); + if (command_name != "!-- --") + sgmlOpenTag(ofs, depth + 1 + command_depth, item_name); break; case LATEX_ENVIRONMENT: @@ -3203,7 +3204,8 @@ switch (style.latextype) { case LATEX_COMMAND: end_tag = "title"; - sgmlCloseTag(ofs, depth + command_depth, end_tag); + if (command_name != "!-- --") + sgmlCloseTag(ofs, depth + command_depth, end_tag); break; case LATEX_ENVIRONMENT: if (!style.latexparam().empty()) @@ -3216,13 +3218,10 @@ sgmlCloseTag(ofs, depth + 1 + command_depth, end_tag); break; case LATEX_PARAGRAPH: - if (style.latexname() != "dummy") - sgmlCloseTag(ofs, depth + command_depth, - style.latexname()); + sgmlCloseTag(ofs, depth + command_depth, style.latexname()); break; default: - sgmlCloseTag(ofs, depth + command_depth, - style.latexname()); + sgmlCloseTag(ofs, depth + command_depth, style.latexname()); break; } } @@ -3248,10 +3247,8 @@ if (!command_stack[j].empty()) sgmlCloseTag(ofs, j, command_stack[j]); - if (!only_body) { - ofs << "\n\n"; - sgmlCloseTag(ofs, 0, top_element); - } + ofs << "\n\n"; + sgmlCloseTag(ofs, 0, top_element); ofs.close(); // How to check for successful close diff -ur lyx-1.1.6cvs/src/insets/insetinclude.C lyx-1.1.6cvs.new/src/insets/insetinclude.C --- lyx-1.1.6cvs/src/insets/insetinclude.C Wed Nov 8 09:39:46 2000 +++ lyx-1.1.6cvs.new/src/insets/insetinclude.C Mon Nov 13 08:16:25 2000 @@ -451,7 +451,9 @@ } if (isVerb()) { - os << "<!-- includefile verbatim=\"" << incfile << "\" -->"; + os << "<inlinegraphic fileref=\"" << '&' << include_label << ';' + << "\" format=\"linespecific\">" + << "</inlinegraphic>"; } else os << '&' << include_label << ';'; @@ -487,7 +489,9 @@ } if (isVerb()) { - os << "<inlinegraphic fileref=\"" << incfile << "\" format=\"linespecific\">"; + os << "<inlinegraphic fileref=\"" << '&' << include_label << ';' + << "\" format=\"linespecific\">" + << "</inlinegraphic>"; } else os << '&' << include_label << ';'; @@ -499,14 +503,15 @@ { string incfile(getContents()); - string writefile = ChangeExtension(getFileName(), ".sgml"); + string writefile; // = ChangeExtension(getFileName(), ".sgml"); + if (!master->tmppath.empty() && !master->niceFile) { incfile = subst(incfile, '/','@'); writefile = AddName(master->tmppath, incfile); } else - // writefile = getFileName(); + writefile = getFileName(); // Use the relative path. - writefile = incfile; + //writefile = incfile; if (IsLyXFilename(getFileName())) writefile = ChangeExtension(writefile, ".sgml"); diff -ur lyx-1.1.6cvs/src/insets/insetlabel.C lyx-1.1.6cvs.new/src/insets/insetlabel.C --- lyx-1.1.6cvs/src/insets/insetlabel.C Thu Sep 28 15:05:24 2000 +++ lyx-1.1.6cvs.new/src/insets/insetlabel.C Mon Nov 13 08:16:25 2000 @@ -88,7 +88,7 @@ int InsetLabel::DocBook(Buffer const *, ostream & os) const { - os << "<anchor id=\"" << getContents() << "\" >"; + os << "<anchor id=\"" << getContents() << "\" ></anchor>"; return 0; } diff -ur lyx-1.1.6cvs/src/support/filetools.C lyx-1.1.6cvs.new/src/support/filetools.C --- lyx-1.1.6cvs/src/support/filetools.C Wed Nov 8 15:19:55 2000 +++ lyx-1.1.6cvs.new/src/support/filetools.C Mon Nov 13 08:16:25 2000 @@ -79,6 +79,12 @@ } +bool IsSGMLFilename(string const & filename) +{ + return contains(filename, ".sgml"); +} + + // Substitutes spaces with underscores in filename (and path) string const MakeLatexName(string const & file) { @@ -730,6 +736,21 @@ // Strip to basename return fname.substr(j + 1); +} + + +// Strips filename from path +string const BasePath(string const & fname) +{ + if (fname.empty()) + return fname; + + string::size_type j = fname.rfind('/'); + if (j == string::npos) // no '/' in fname + return string(); + + // Strip to basename + return fname.substr(0,j + 1); } diff -ur lyx-1.1.6cvs/src/support/filetools.h lyx-1.1.6cvs.new/src/support/filetools.h --- lyx-1.1.6cvs/src/support/filetools.h Wed Nov 8 09:39:46 2000 +++ lyx-1.1.6cvs.new/src/support/filetools.h Mon Nov 13 08:16:25 2000 @@ -83,6 +83,9 @@ /// bool IsLyXFilename(string const & filename); +/// +bool IsSGMLFilename(string const & filename); + /** Returns the path of a library data file. Search the file name.ext in the subdirectory dir of \begin{enumerate} @@ -190,6 +193,9 @@ /// Strips path from filename string const OnlyFilename(string const & fname); + +/// Strips filename from path +string const BasePath(string const & fname); /// Get the contents of a file as a huge string string const GetFileContents(string const & fname);