From 922ed31d7aff55d7ea764ec89aa1d9fd77c53261 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Matox?= Date: Tue, 23 Oct 2001 09:42:14 +0000 Subject: [PATCH] Cleaned the preamble generation for linuxdoc/docbook. 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 | 14 +++++++++++++ src/LaTeXFeatures.C | 14 +++++++++++++ src/LaTeXFeatures.h | 2 ++ src/buffer.C | 31 +++++++++++++++------------- src/insets/ChangeLog | 7 +++++++ src/insets/insetref.C | 2 +- src/insets/insetspecialchar.C | 38 +++++++++++++++++++++++++++++++++-- src/tabular.C | 2 +- 8 files changed, 92 insertions(+), 18 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8e86c9a220..51aec6e64e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2001-10-23 José Matos + + * 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 * sp_pspell.h (class PSpell): add alive function needed in the diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index cd23dcf7ab..0f4d8dd2fa 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -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 << "" + << '\n'; + } + + return entities.str().c_str(); +} + + string const LaTeXFeatures::getIncludedFiles(string const & fname) const { ostringstream sgmlpreamble; diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 7926fa206d..be168ffef2 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -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; /// diff --git a/src/buffer.C b/src/buffer.C index c29803f02b..fca885ff86 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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 << "\n\n"; - } else { - ofs << "\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 << "\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; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 37d0875332..31d7bef1f7 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ +2001-10-23 José Matos + + * 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 * insettext.C (checkInsertChar): added for REALLY checking the diff --git a/src/insets/insetref.C b/src/insets/insetref.C index 5ce084749f..e9d2c8d69d 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -88,7 +88,7 @@ int InsetRef::linuxdoc(Buffer const *, ostream & os) const int InsetRef::docbook(Buffer const *, ostream & os) const { if (getOptions().empty()) { - os << ""; + os << ""; } else { os << "" << getOptions() << ""; diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index f328320c22..0524855dc0 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -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 << " "; + 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 << " "; + break; + } + return 0; } diff --git a/src/tabular.C b/src/tabular.C index 6c5d2f388c..1052d80565 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2308,7 +2308,7 @@ int LyXTabular::DocBook(Buffer const * buf, ostream & os) const os << "center"; break; } - os << "\"/>\n"; + os << "\">\n"; ++ret; } -- 2.39.5