]> git.lyx.org Git - features.git/commitdiff
Cleaned the preamble generation for linuxdoc/docbook.
authorJosé Matox <jamatos@lyx.org>
Tue, 23 Oct 2001 09:42:14 +0000 (09:42 +0000)
committerJosé Matox <jamatos@lyx.org>
Tue, 23 Oct 2001 09:42:14 +0000 (09:42 +0000)
Added lyx generated SGML entities (now only for the menu separator).
Cleaned the code from XML-ism.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2921 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/LaTeXFeatures.C
src/LaTeXFeatures.h
src/buffer.C
src/insets/ChangeLog
src/insets/insetref.C
src/insets/insetspecialchar.C
src/tabular.C

index 8e86c9a2205681162679cf61aa25508b78bcbaa0..51aec6e64e21136f8e1041c93d78c5424b752ddd 100644 (file)
@@ -1,3 +1,17 @@
+2001-10-23  José Matos  <jamatos@fep.up.pt>
+
+       * LaTeXFeatures.h:
+       * LaTeXFeatures.C (getLyXSGMLEntities): new function to get the name
+       of the lyx defined sgml entities used in a docbook/linuxdoc document.
+
+       * buffer.C (makeLinuxDocFile):
+       (makeDocBookFile): reworked the preamble, more clean, and with
+       support for lyx defined entities. Changed the document declaration
+       to be more XML friendly.
+
+       * tabular.C (DocBook): removed / terminator to be more SGML friendly,
+       if we need to output XML that should be done with a filter.
+       
 2001-10-22  Juergen Vigna  <jug@sad.it>
 
        * sp_pspell.h (class PSpell): add alive function needed in the
index cd23dcf7abc6554403fe0cf674ef1209d3e1346a..0f4d8dd2faad20570f8f4022233fcc8f5a5cb473 100644 (file)
@@ -375,6 +375,20 @@ string const LaTeXFeatures::getTClassPreamble() const
 }      
 
 
+string const LaTeXFeatures::getLyXSGMLEntities() const
+{
+       // Definition of entities used in the document that are LyX related.
+       ostringstream entities;
+
+       if (lyxarrow) {
+               entities << "<!ENTITY lyxarrow \"-&gt;\">"
+                        << '\n';
+       }
+
+       return entities.str().c_str();
+}
+
+
 string const LaTeXFeatures::getIncludedFiles(string const & fname) const
 {
        ostringstream sgmlpreamble;
index 7926fa206d62a84e21e305f0f4aaa4dd78754156..be168ffef28cd6ba5f5ad573ece3e2a07217de10 100644 (file)
@@ -41,6 +41,8 @@ struct LaTeXFeatures {
        string const getMacros() const;
        /// The definitions needed by the document's textclass
        string const getTClassPreamble() const;
+       /// The sgml definitions needed by the document (dobook/linuxdoc)
+       string const getLyXSGMLEntities() const;
        ///
        string const getIncludedFiles(string const & fname) const;
        ///
index c29803f02b834d13c1e35d950ef323d486b4b07c..fca885ff86c2c4444049555cde4666718b4147ba 100644 (file)
@@ -2561,14 +2561,16 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
        string top_element = textclasslist.LatexnameOfClass(params.textclass);
 
        if (!body_only) {
-               string sgml_includedfiles=features.getIncludedFiles(fname);
+               ofs << "<!doctype linuxdoc system";
 
-               if (params.preamble.empty() && sgml_includedfiles.empty()) {
-                       ofs << "<!doctype linuxdoc system>\n\n";
-               } else {
-                       ofs << "<!doctype linuxdoc system [ "
-                           << params.preamble << sgml_includedfiles << " \n]>\n\n";
+               string preamble = params.preamble;
+               preamble += features.getIncludedFiles(fname);
+               preamble += features.getLyXSGMLEntities();
+
+               if (!preamble.empty()) {
+                       ofs << " [ " << preamble << " ]";
                }
+               ofs << ">\n\n";
 
                if (params.options.empty())
                        sgmlOpenTag(ofs, 0, top_element);
@@ -3025,16 +3027,17 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
        string top_element = textclasslist.LatexnameOfClass(params.textclass);
 
        if (!only_body) {
-               string sgml_includedfiles = features.getIncludedFiles(fname);
+               ofs << "<!DOCTYPE " << top_element
+                   << "  PUBLIC \"-//OASIS//DTD DocBook V3.1//EN\"";
 
-               ofs << "<!doctype " << top_element
-                   << " public \"-//OASIS//DTD DocBook V3.1//EN\"";
+               string preamble = params.preamble;
+               preamble += features.getIncludedFiles(fname);
+               preamble += features.getLyXSGMLEntities();
 
-               if (params.preamble.empty() && sgml_includedfiles.empty())
-                       ofs << ">\n\n";
-               else
-                       ofs << "\n [ " << params.preamble 
-                           << sgml_includedfiles << " \n]>\n\n";
+               if (!preamble.empty()) {
+                       ofs << "\n [ " << preamble << " ]";
+               }
+               ofs << ">\n\n";
        }
 
        string top = top_element;       
index 37d087533287ccfccd30451725e4aaad222fbd9e..31d7bef1f710f6d0c519e813e409261fe1f7b78c 100644 (file)
@@ -1,3 +1,10 @@
+2001-10-23  José Matos  <jamatos@fep.up.pt>
+
+       * insetref.C (docbook): removed / terminator to conform SGML.
+
+       * insetspecialchar.C (linuxdoc):
+       (docbook): Added support for special chars, more than ascii export.
+
 2001-10-22  Juergen Vigna  <jug@sad.it>
 
        * insettext.C (checkInsertChar): added for REALLY checking the
index 5ce084749fd26556d8dec77fdb015bc7323ae2ee..e9d2c8d69d143af4a9b38e5dbdd2b76440732bdb 100644 (file)
@@ -88,7 +88,7 @@ int InsetRef::linuxdoc(Buffer const *, ostream & os) const
 int InsetRef::docbook(Buffer const *, ostream & os) const
 {
        if (getOptions().empty()) {
-               os << "<xref linkend=\"" << getContents() << "\"/>";
+               os << "<xref linkend=\"" << getContents() << "\">";
        } else {
                os << "<link linkend=\"" << getContents()
                   << "\">" << getOptions() << "</link>";
index f328320c227ba8c79c8b97068530f9acb75c2089..0524855dc050f543e523a4e94337d79f5377ec68 100644 (file)
@@ -265,13 +265,47 @@ int InsetSpecialChar::ascii(Buffer const *, ostream & os, int) const
 
 int InsetSpecialChar::linuxdoc(Buffer const * buf, ostream & os) const
 {
-       return ascii(buf, os, 0);
+       switch (kind_) {
+       case HYPHENATION:
+       case LIGATURE_BREAK:
+               break;
+       case END_OF_SENTENCE:
+               os << ".";
+               break;
+       case LDOTS:
+               os << "...";    
+               break;
+       case MENU_SEPARATOR:      
+               os << "&lyxarrow;"; 
+               break;
+       case PROTECTED_SEPARATOR:
+               os << "&nbsp;";
+               break;
+       }
+       return 0;
 }
 
 
 int InsetSpecialChar::docbook(Buffer const * buf, ostream & os) const
 {
-       return ascii(buf, os, 0);
+       switch (kind_) {
+       case HYPHENATION:
+       case LIGATURE_BREAK:
+               break;
+       case END_OF_SENTENCE:
+               os << ".";
+               break;
+       case LDOTS:
+               os << "...";    
+               break;
+       case MENU_SEPARATOR:
+               os << "&lyxarrow;";
+               break;
+       case PROTECTED_SEPARATOR:
+               os << "&nbsp;";
+               break;
+       }
+       return 0;
 }
 
 
index 6c5d2f388c3055079546c7f0efe12d579168b851..1052d8056541c1edace72bf6e8f896613a6c9086 100644 (file)
@@ -2308,7 +2308,7 @@ int LyXTabular::DocBook(Buffer const * buf, ostream & os) const
                        os << "center";
                        break;
                }
-               os << "\"/>\n";
+               os << "\">\n";
                ++ret;
        }