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
This commit is contained in:
José Matox 2001-10-23 09:42:14 +00:00
parent e7739010d4
commit 922ed31d7a
8 changed files with 92 additions and 18 deletions

View 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

View 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;

View 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;
///

View 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;

View 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

View 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>";

View 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;
}

View File

@ -2308,7 +2308,7 @@ int LyXTabular::DocBook(Buffer const * buf, ostream & os) const
os << "center";
break;
}
os << "\"/>\n";
os << "\">\n";
++ret;
}