diff --git a/ChangeLog b/ChangeLog index 426c50e728..d4879ea4ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2000-11-13 José Abílio Matos + + * 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 Miyata Shigeru * development/OS2/quick_fix.patch: diff --git a/lib/layouts/docbook-book.layout b/lib/layouts/docbook-book.layout index 98f536aa65..26839ca00a 100644 --- a/lib/layouts/docbook-book.layout +++ b/lib/layouts/docbook-book.layout @@ -163,6 +163,7 @@ End # SGML style definition Style SGML CopyStyle LaTeX + LatexName "!-- --" End # There are no chapters or parts in an docbook article. diff --git a/lib/layouts/docbook.layout b/lib/layouts/docbook.layout index ba1315ad83..8110d6eeba 100644 --- a/lib/layouts/docbook.layout +++ b/lib/layouts/docbook.layout @@ -153,6 +153,7 @@ End # SGML style definition Style SGML CopyStyle LaTeX + LatexName "!-- --" End # There are no chapters or parts in an docbook article. diff --git a/lib/layouts/linuxdoc.layout b/lib/layouts/linuxdoc.layout index a3d7446807..f7cc48613d 100644 --- a/lib/layouts/linuxdoc.layout +++ b/lib/layouts/linuxdoc.layout @@ -368,7 +368,7 @@ End Style SGML Margin Static LatexType Paragraph - LatexName dummy + LatexName "!-- --" NewLine 0 ParIndent MM ParSkip 0.4 diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index a50eac97fc..d57a495bc4 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -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::getTClassPreamble() } -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 += "\nfirst - + " system \"" + fi->second + "\">"; + sgmlpreamble += "\nfirst + + (IsSGMLFilename(fi->second) ? " SYSTEM \"" : " \"" ) + + MakeRelPath(fi->second,basename) + "\">"; return sgmlpreamble; } diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 91165ad7f0..8c3cd68b9a 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -42,7 +42,7 @@ struct LaTeXFeatures { /// The definitions needed by the document's textclass string const getTClassPreamble(); /// - string const getIncludedFiles(); + string const getIncludedFiles(string const fname) const; /// void showStruct(); diff --git a/src/buffer.C b/src/buffer.C index 1d7973a8ff..869ab7d367 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2336,14 +2336,16 @@ bool Buffer::isSGML() const 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, ' ') << "\n"; + if (latexname != "!-- --") + os << string(depth, ' ') << "\n"; } @@ -2380,7 +2382,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) texrow.reset(); if (!body_only) { - string sgml_includedfiles=features.getIncludedFiles(); + string sgml_includedfiles=features.getIncludedFiles(fname); if (params.preamble.empty() && sgml_includedfiles.empty()) { ofs << "\n\n"; @@ -3000,7 +3002,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) texrow.reset(); if (!only_body) { - string sgml_includedfiles=features.getIncludedFiles(); + string sgml_includedfiles=features.getIncludedFiles(fname); ofs << "\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 << ""; + os << "" + << ""; } else os << '&' << include_label << ';'; @@ -487,7 +489,9 @@ int InsetInclude::DocBook(Buffer const * buffer, ostream & os) const } if (isVerb()) { - os << ""; + os << "" + << ""; } else os << '&' << include_label << ';'; @@ -499,14 +503,15 @@ void InsetInclude::Validate(LaTeXFeatures & features) const { 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 --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 72376e4427..80428c3b67 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -88,7 +88,7 @@ int InsetLabel::Linuxdoc(Buffer const *, ostream & os) const int InsetLabel::DocBook(Buffer const *, ostream & os) const { - os << ""; + os << ""; return 0; } diff --git a/src/support/filetools.C b/src/support/filetools.C index a85f4a1091..6e91bf695f 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -79,6 +79,12 @@ bool IsLyXFilename(string const & filename) } +bool IsSGMLFilename(string const & filename) +{ + return contains(filename, ".sgml"); +} + + // Substitutes spaces with underscores in filename (and path) string const MakeLatexName(string const & file) { @@ -733,6 +739,21 @@ string const OnlyFilename(string const & fname) } +// 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); +} + + // Is a filename/path absolute? bool AbsolutePath(string const & path) { diff --git a/src/support/filetools.h b/src/support/filetools.h index f42c539749..354393f4fa 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -83,6 +83,9 @@ int IsFileWriteable (string const & path); /// 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} @@ -191,6 +194,9 @@ string const NormalizePath(string const & path); /// 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);