diff --git a/src/ChangeLog b/src/ChangeLog index 0955a93515..d7281a345b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2004-10-30 José Matos + + * output_docbook.C (makeParagraphs): + * paragraph.[Ch] (emptyTag): for docbook and company, if the + standard paragraph has only a given type of content drop the wrapper. + 2004-10-29 José Matos * output_docbook.C (makeEnvironment): diff --git a/src/output_docbook.C b/src/output_docbook.C index 69e04977d0..47c8eefd47 100644 --- a/src/output_docbook.C +++ b/src/output_docbook.C @@ -102,11 +102,16 @@ ParagraphList::const_iterator makeParagraph(Buffer const & buf, ParagraphList::const_iterator const & pbegin, ParagraphList::const_iterator const & pend) { + LyXLayout_ptr const & defaultstyle = buf.params().getLyXTextClass().defaultLayout(); for(ParagraphList::const_iterator par = pbegin; par != pend; ++par) { - sgml::openTag(buf, os, *par); - par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs)); - sgml::closeTag(os, *par); - os << '\n'; + if (par->layout() == defaultstyle && par->emptyTag()) { + par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs)); + } else { + sgml::openTag(buf, os, *par); + par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs)); + sgml::closeTag(os, *par); + os << '\n'; + } } return pend; } diff --git a/src/paragraph.C b/src/paragraph.C index 95d8bbfb97..d6ff30fc86 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1331,6 +1331,31 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf, } +bool Paragraph::emptyTag() 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::TOC_CODE and + lyx_code != InsetBase::INCLUDE_CODE and + lyx_code != InsetBase::GRAPHICS_CODE and + lyx_code != InsetBase::ERT_CODE and + lyx_code != InsetBase::FLOAT_CODE and + lyx_code != InsetBase::TABULAR_CODE) { + return false; + } + } else { + char c = getChar(i); + if(c!= ' ' and c!= '\t') + return false; + } + + } + return true; +} + + string Paragraph::getID() const { for (pos_type i = 0; i < size(); ++i) { diff --git a/src/paragraph.h b/src/paragraph.h index a204661bc6..d72caec520 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -122,13 +122,16 @@ public: LyXFont const & outerfont, std::ostream &, TexRow & texrow, OutputParams const &) const; - /// + /// Writes to stream the content of the paragraph for linuxdoc void simpleLinuxDocOnePar(Buffer const & buf, std::ostream & os, LyXFont const & outerfont, OutputParams const & runparams, lyx::depth_type depth) const; + /// Can we drop the standard paragraph wrapper? + bool Paragraph::emptyTag() const; + /// Get the id of the paragraph, usefull for docbook and linuxdoc std::string getID() const;