From 33243f70037b067f90d1574b74b34f90a2ef2aa1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Matox?= Date: Fri, 14 May 2004 15:47:35 +0000 Subject: [PATCH] clean code to export between different flavours, output different code for sgml to deal with incomplete implementation, clean code git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8755 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 6 ++++++ lib/layouts/agu_stdclass.inc | 2 +- lib/layouts/db_stdclass.inc | 2 +- src/ChangeLog | 11 +++++++++++ src/buffer.C | 16 +++++++++++++--- src/insets/ChangeLog | 4 ++++ src/insets/insetlabel.C | 2 +- src/output_docbook.C | 31 +++++++++++-------------------- src/paragraph.C | 33 ++++++++++++++++++++++----------- src/paragraph.h | 6 ++++-- src/sgml.C | 2 ++ 11 files changed, 76 insertions(+), 39 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index c15f69f51c..784586ef1f 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2004-05-14 José Matos + + * layouts/agu_stdclass.inc: + * layouts/db_stdclass.inc: remove !DOCTYPE from the Formal Public + Identifier since this is an invariant. + 2004-05-13 José Matos * configure.m4: add support for docbook-xml. diff --git a/lib/layouts/agu_stdclass.inc b/lib/layouts/agu_stdclass.inc index c3cc819529..596a04eb71 100644 --- a/lib/layouts/agu_stdclass.inc +++ b/lib/layouts/agu_stdclass.inc @@ -15,7 +15,7 @@ TocDepth 3 DefaultStyle Standard ClassOptions - Header " + + * buffer.C (makeDocBookFile): add a default Formal Public Identifier + if the textclass does not provide it. Have it different for sgml and + xml. + support the language of document. + * output_docbook.C (docbookParagraphs): + * paragraph.[Ch] (getDocbookId): new function that gets the id of the + first anchor as the id of the paragraph, remove special case code. + * sgml.C (escapeChar): escape only < & >. + 2004-05-14 Angus Leeming * bufferparams.h: move biblio::CiteEngine enum here to minimize diff --git a/src/buffer.C b/src/buffer.C index a1ae1f6f48..94bdf87d91 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1070,8 +1070,15 @@ void Buffer::makeDocBookFile(string const & fname, ofs << "encoding()->Name() << "\"?>\n"; - ofs << subst(tclass.class_header(), "#", top_element); - + ofs << "filename, ".sgml") : fname; @@ -1086,7 +1093,10 @@ void Buffer::makeDocBookFile(string const & fname, string top = top_element; top += " lang=\""; - top += params().language->code(); + if (runparams.flavor == OutputParams::XML) + top += params().language->code(); + else + top += params().language->code().substr(0,2); top += '"'; if (!params().options.empty()) { diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 649cfb32cd..c5102b412d 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2004-05-14 José Matos + + * insetlabel (docbook): do not ouput label, for the moment. + 2004-05-14 Angus Leeming * insetcite.C (getNatbibLabel, generateLabel, latex): use the diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index c96ea56b81..816821f9c7 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -143,6 +143,6 @@ int InsetLabel::linuxdoc(Buffer const &, ostream & os, int InsetLabel::docbook(Buffer const &, ostream & os, OutputParams const &) const { - os << ""; + os << ""; return 0; } diff --git a/src/output_docbook.C b/src/output_docbook.C index 7caa4b518c..77faddc5b1 100644 --- a/src/output_docbook.C +++ b/src/output_docbook.C @@ -67,7 +67,7 @@ void docbookParagraphs(Buffer const & buf, ParagraphList::iterator par = const_cast(paragraphs).begin(); ParagraphList::iterator pend = const_cast(paragraphs).end(); - Counters & counters = buf.params().getLyXTextClass().counters(); + Counters & counters = buf.params().getLyXTextClass().counters(); for (; par != pend; ++par) { @@ -93,8 +93,10 @@ void docbookParagraphs(Buffer const & buf, environment_inner[depth].erase(); } - string ls = ""; - bool labelid = false; + string ls = par->getDocbookId(); + if (!ls.empty()) + ls = " id = \"" + ls + "\""; + // Write opening SGML tags. switch (style->latextype) { case LATEX_PARAGRAPH: @@ -103,6 +105,7 @@ void docbookParagraphs(Buffer const & buf, int i = counters.value("para"); ls = subst(style->latexparam(), "#", tostr(i)); } + sgml::openTag(os, depth + command_depth, false, style->latexname(), ls); break; @@ -144,20 +147,8 @@ void docbookParagraphs(Buffer const & buf, if (style->latexparam().find('#') != string::npos) { counters.step(style->counter); } - // treat label as a special case for - // more WYSIWYM handling. - // This is a hack while paragraphs can't have - // attributes, like id in this case. - if (par->size() && par->isInset(0)) { - InsetBase * inset = par->getInset(0); - if (inset->lyxCode() == InsetOld::LABEL_CODE) { - command_name += " id=\""; - command_name += (static_cast(inset))->getContents(); - command_name += '"'; - labelid = true; - } - } - if (!labelid && !style->latexparam().empty()) { + + if (!style->latexparam().empty()) { ls = style->latexparam(); if (ls.find('#') != string::npos) { string el = expandLabel(buf.params().getLyXTextClass(), @@ -198,7 +189,7 @@ void docbookParagraphs(Buffer const & buf, environment_inner[depth] = "!-- --"; // outputs sgml::openTag(os, depth + command_depth, false, - environment_stack[depth], style->latexparam()); + environment_stack[depth], style->latexparam() + ls); } else { sgml::closeEnvTags(os, false, environment_inner[depth], style->itemtag(), command_depth + depth); @@ -223,13 +214,13 @@ void docbookParagraphs(Buffer const & buf, break; default: sgml::openTag(os, depth + command_depth, - false, style->latexname()); + false, style->latexname(), ls); break; } par->simpleDocBookOnePar(buf, os, outerFont(par - const_cast(paragraphs).begin(), paragraphs), - runparams, depth + 1 + command_depth, labelid); + runparams, depth + 1 + command_depth); // write closing SGML tags switch (style->latextype) { diff --git a/src/paragraph.C b/src/paragraph.C index 5a7131ab3c..ede6729f74 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1325,12 +1325,27 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf, } +string Paragraph::getDocbookId() const +{ + for (pos_type i = 0; i < size(); ++i) { + if (isInset(i)) { + InsetBase const * inset = getInset(i); + InsetBase::Code lyx_code = inset->lyxCode(); + if (lyx_code == InsetBase::LABEL_CODE) { + return static_cast(inset)->getContents(); + } + } + + } + return string(); +} + + void Paragraph::simpleDocBookOnePar(Buffer const & buf, ostream & os, LyXFont const & outerfont, OutputParams const & runparams, - lyx::depth_type depth, - bool labelid) const + lyx::depth_type depth) const { bool emph_flag = false; @@ -1392,15 +1407,11 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, if (isInset(i)) { InsetBase const * inset = getInset(i); - // don't print the inset in position 0 if desc_on == 3 (label) - //if (i || desc_on != 3) { - if (!labelid) { - if (style->latexparam() == "CDATA") - os << "]]>"; - inset->docbook(buf, os, runparams); - if (style->latexparam() == "CDATA") - os << "latexparam() == "CDATA") + os << "]]>"; + inset->docbook(buf, os, runparams); + if (style->latexparam() == "CDATA") + os << " escapeChar(char c) case '>': str = ">"; break; +#if 0 case '$': str = "$"; break; @@ -76,6 +77,7 @@ pair escapeChar(char c) case '\\': str = "\"; break; +#endif default: str = c; break; -- 2.39.5