From: Martin Vermeer Date: Tue, 25 Nov 2003 17:23:36 +0000 (+0000) Subject: Introducing a number of tags parametrizing various X-Git-Tag: 1.6.10~15749 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=af37f0d23e8aab1bfbd7ab7f26a10e7685dfca68;p=features.git Introducing a number of tags parametrizing various XML formats that we may want to support git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8137 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 3958993e13..be33917e45 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,23 @@ + +2003-11-25 Martin Vermeer + + * lib/layouts/agu-dtd.layout: + * lib/layouts/agu_stdclass.inc: + * lib/layouts/agu_stdcounters.inc: + * lib/layouts/agu_stdlists.inc: + * lib/layouts/agu_stdsections.inc: + * lib/layouts/db_lyxmacros.inc: + * lib/layouts/db_stdclass.inc: + * lib/layouts/db_stdlayouts.inc: + * lib/layouts/db_stdlists.inc: + * lib/layouts/db_stdstarsections.inc: + * lib/layouts/db_stdstruct.inc: + * lib/layouts/db_stdtitle.inc: + * lib/layouts/docbook-book.layout: + * lib/layouts/docbook-chapter.layout: + * lib/layouts/docbook-section.layout: Introducing a number of tags + parametrizing various XML formats that we may want to support + 2003-11-17 Roman Maurer * examples/sl_splash.lyx: update diff --git a/lib/layouts/agu-dtd.layout b/lib/layouts/agu-dtd.layout new file mode 100644 index 0000000000..e89cddb3b4 --- /dev/null +++ b/lib/layouts/agu-dtd.layout @@ -0,0 +1,14 @@ +#% Do not delete the line below; configure depends on this +# \DeclareDocBookClass[AGU-article]{AGU Article (SGML)} +# AGU XML textclass definition file. +# Authors : Jose' Matos +# Martin Vermeer + + +Input agu_stdclass.inc +Input numarticle.inc + + +# Exclude higher, or equal, sections: +NoStyle Part +NoStyle Chapter diff --git a/lib/layouts/agu_stdclass.inc b/lib/layouts/agu_stdclass.inc new file mode 100644 index 0000000000..d703636ffa --- /dev/null +++ b/lib/layouts/agu_stdclass.inc @@ -0,0 +1,89 @@ +# Textclass definition file for AGU-Article. +# Author : José Abílio Oliveira Matos +# Martin Vermeer + +# This file is the counterpart of stdclass.inc +# It is desirable, as far as possible, to have the same look and feel for +# related layouts in latex and docbook. + +OutputType docbook + +Columns 1 +Sides 1 +SecNumDepth 3 +TocDepth 3 +DefaultStyle Standard + + +Style Standard + Margin Static + LatexType Paragraph + LatexName p + ParIndent MM + ParSkip 0.4 + Align Block + AlignPossible Block + LabelType No_Label + LatexParam "para#" +End + + +CharStyle Firstname + LatexType Command + LatexName firstname + Font + Shape SmallCaps + EndFont + LabelFont + Shape Italic + Color red + EndFont +End + +CharStyle Surname + LatexType Command + LatexName firstname + Font + Shape SmallCaps + EndFont + LabelFont + Shape Italic + Color red + EndFont +End + +CharStyle Filename + LatexType Command + LatexName firstname + Font + Family Typewriter + EndFont + LabelFont + Shape Italic + Color red + EndFont +End + +CharStyle Literal + LatexType Command + LatexName firstname + Font + Family Typewriter + EndFont + LabelFont + Shape Italic + Color red + EndFont +End + + +Input agu_stdlists.inc +Input agu_stdsections.inc +Input db_stdstarsections.inc +Input db_stdtitle.inc +Input db_stdstruct.inc +Input db_lyxmacros.inc +Input db_stdlayouts.inc +Input stdcounters.inc +Input agu_stdcounters.inc +Input stdfloats.inc diff --git a/lib/layouts/agu_stdcounters.inc b/lib/layouts/agu_stdcounters.inc new file mode 100644 index 0000000000..84434517b0 --- /dev/null +++ b/lib/layouts/agu_stdcounters.inc @@ -0,0 +1,34 @@ +# Author : José Matos +# Martin Vermeer + +# This include file contains all the counters that are defined as standard +# in AGU-Article LyX layouts. + +Counter + Name sect1 + Within section +End + +Counter + Name sect2 + Within sect1 +End + +Counter + Name sect3 + Within sect2 +End + +Counter + Name sect4 + Within sect3 +End + +Counter + Name sect5 + Within sect4 +End + +Counter + Name para +End diff --git a/lib/layouts/agu_stdlists.inc b/lib/layouts/agu_stdlists.inc new file mode 100644 index 0000000000..769415dff2 --- /dev/null +++ b/lib/layouts/agu_stdlists.inc @@ -0,0 +1,37 @@ +# Textclass definition file for AGU-Article. +# Author : José Abílio Oliveira Matos +# Martin Vermeer + +# This is the counterpart of stdlists.inc +# It is desirable, as far as possible, to have the same look and feel for +# related layouts in latex and docbook. + +Input stdlists.inc + + +Style Itemize + LatexType Item_Environment + LatexName lst + Latexparam "type="bulleted"" + ItemTag item +End + + +Style Enumerate + LatexType Item_Environment + LatexName lst + Latexparam "type="ordered"" + ItemTag item +End + + +Style Description + LatexType Item_environment + LatexName lst + Latexparam "type="unordered"" + ItemTag item +End + +# maybe List is the same as simplelist (I need to check it). +NoStyle List + diff --git a/lib/layouts/agu_stdsections.inc b/lib/layouts/agu_stdsections.inc new file mode 100644 index 0000000000..616d1f59cb --- /dev/null +++ b/lib/layouts/agu_stdsections.inc @@ -0,0 +1,86 @@ +# Textclass definition file for docbook. +# Author : José Abílio Oliveira Matos +# Martin Vermeer + +# This file is the counterpart of stdsections.inc +# It is desirable, as far as possible, to have the same look and feel for +# related layouts in latex and docbook. + +Input stdsections.inc + +Style Part + LatexType Command + LatexName part + InnerTag head + LabelTag label + CommandDepth 0 +End + + +Style Chapter + LatexType Command + LatexName chapter + InnerTag head + LabelTag label + CommandDepth 1 +End + + +Style Section + LatexType Command + LatexName section + InnerTag head + LabelTag label + CommandDepth 2 + LatexParam "s#" +End + + +Style Subsection + LatexType Command + LatexName subsect1 + InnerTag head + LabelTag label + CommandDepth 3 + LatexParam "s#" +End + + +Style Subsubsection + LatexType Command + LatexName subsect2 + InnerTag head + LabelTag label + CommandDepth 4 + LatexParam "s#" +End + + +Style Paragraph + LatexType Command + LatexName subsect3 + InnerTag head + LabelTag label + CommandDepth 5 + LatexParam "s#" +End + + +Style Subparagraph + LatexType Command + LatexName subsect4 + InnerTag head + LabelTag label + CommandDepth 6 + LatexParam "s#" +End + +Style Subsubparagraph + LatexType Command + LatexName subsect5 + InnerTag head + LabelTag label + CommandDepth 7 + LatexParam "s#" +End + diff --git a/lib/layouts/db_lyxmacros.inc b/lib/layouts/db_lyxmacros.inc index 36c01a2e34..09e0a0c0c3 100644 --- a/lib/layouts/db_lyxmacros.inc +++ b/lib/layouts/db_lyxmacros.inc @@ -2,7 +2,7 @@ # Author : José Abílio Oliveira Matos # This is the counterpart of lyxmacros.inc -# It is desireable, as far as possible, to have the same look and feeling for +# It is desirable, as far as possible, to have the same look and feel for # related layouts in latex and docbook. Input lyxmacros.inc @@ -11,7 +11,7 @@ Style Code CopyStyle LyX-Code LatexType Environment LatexName programlisting - LatexParam CDATA + InnerTag CDATA PassThru 1 End diff --git a/lib/layouts/db_stdclass.inc b/lib/layouts/db_stdclass.inc index 154875cde8..845207050e 100644 --- a/lib/layouts/db_stdclass.inc +++ b/lib/layouts/db_stdclass.inc @@ -2,7 +2,7 @@ # Author : José Abílio Oliveira Matos # This file is the counterpart of stdclass.inc -# It is desireable, as far as possible, to have the same look and feeling for +# It is desirable, as far as possible, to have the same look and feel for # related layouts in latex and docbook. OutputType docbook @@ -38,7 +38,7 @@ CharStyle Filename EndFont End -CharStyle FirstName +CharStyle Firstname LatexType Command LatexName firstname Font diff --git a/lib/layouts/db_stdlayouts.inc b/lib/layouts/db_stdlayouts.inc index 03fa96ce91..ea6f2b8a80 100644 --- a/lib/layouts/db_stdlayouts.inc +++ b/lib/layouts/db_stdlayouts.inc @@ -2,7 +2,7 @@ # Author : José Abílio Oliveira Matos # This is the counterpart of stdlayouts.inc -# It is desireable, as far as possible, to have the same look and feeling for +# It is desirable, as far as possible, to have the same look and feel for # related layouts in latex and docbook. Input stdlayouts.inc @@ -34,7 +34,7 @@ End Style Quotation LatexType Environment LatexName blockquote - LatexParam para + InnerTag para End # Quote should be an inline element diff --git a/lib/layouts/db_stdlists.inc b/lib/layouts/db_stdlists.inc index 73340768fa..739b1d2651 100644 --- a/lib/layouts/db_stdlists.inc +++ b/lib/layouts/db_stdlists.inc @@ -2,7 +2,7 @@ # Author : José Abílio Oliveira Matos # This is the counterpart of stdlists.inc -# It is desireable, as far as possible, to have the same look and feeling for +# It is desirable, as far as possible, to have the same look and feel for # related layouts in latex and docbook. Input stdlists.inc @@ -11,18 +11,23 @@ Input stdlists.inc Style Itemize LatexType Item_Environment LatexName itemizedlist + ItemTag listitem End Style Enumerate LatexType Item_Environment LatexName orderedlist + ItemTag listitem End Style Description LatexType Item_environment LatexName variablelist + InnerTag varlistentry + LabelTag term + ItemTag listitem End # maybe List is the same as simplelist (I need to check it). diff --git a/lib/layouts/db_stdstarsections.inc b/lib/layouts/db_stdstarsections.inc index b84ddb645b..27d96880b9 100644 --- a/lib/layouts/db_stdstarsections.inc +++ b/lib/layouts/db_stdstarsections.inc @@ -2,7 +2,7 @@ # Author : José Abílio Oliveira Matos # This file is the counterpart of stdstarsections.inc -# It is desireable, as far as possible, to have the same look and feeling for +# It is desirable, as far as possible, to have the same look and feel for # related layouts in latex and docbook. # empty for now, it is possible to do it using bridgehead with attribute diff --git a/lib/layouts/db_stdstruct.inc b/lib/layouts/db_stdstruct.inc index d30e3bef30..7a1d7e33b4 100644 --- a/lib/layouts/db_stdstruct.inc +++ b/lib/layouts/db_stdstruct.inc @@ -2,7 +2,7 @@ # Author : José Abílio Oliveira Matos # This file is the counterpart of stdstruct.inc -# It is desireable, as far as possible, to have the same look and feeling for +# It is desirable, as far as possible, to have the same look and feel for # related layouts in latex and docbook. Input stdstruct.inc @@ -10,7 +10,7 @@ Input stdstruct.inc Style Abstract LatexType Environment LatexName abstract - LatexParam para + InnerTag para End NoStyle Bibliography diff --git a/lib/layouts/db_stdtitle.inc b/lib/layouts/db_stdtitle.inc index e1025fa254..97067bf645 100644 --- a/lib/layouts/db_stdtitle.inc +++ b/lib/layouts/db_stdtitle.inc @@ -13,7 +13,7 @@ Style Title LatexType Command LatexName articleinfo CommandDepth 2 - InnerTag "title" + InnerTag title End @@ -28,7 +28,7 @@ Style Authorgroup CopyStyle Author LatexType Environment LatexName authorgroup - LatexParam author + InnerTag author End @@ -68,7 +68,8 @@ Style RevisionHistory Margin Static LatexType Command LatexName revhistory - LatexParam "3|!-- --" + CommandDepth 3 + InnerTag "!-- --" LeftMargin MMM RightMargin MMM ParIndent MM @@ -88,7 +89,8 @@ Style Revision Margin Dynamic LatexType Command LatexName revision - LatexParam "4|revnumber" + CommandDepth 4 + InnerTag revnumber LabelSep xxx ParSkip 0.4 TopSep 0.9 diff --git a/lib/layouts/docbook-book.layout b/lib/layouts/docbook-book.layout index bc34131e45..66f673b800 100644 --- a/lib/layouts/docbook-book.layout +++ b/lib/layouts/docbook-book.layout @@ -11,5 +11,5 @@ Input report Style Title LatexType Command LatexName bookinfo - LatexParam "1|" + CommandDepth 1 End diff --git a/lib/layouts/docbook-chapter.layout b/lib/layouts/docbook-chapter.layout index 00dd927b3a..7c9c98915e 100644 --- a/lib/layouts/docbook-chapter.layout +++ b/lib/layouts/docbook-chapter.layout @@ -10,7 +10,7 @@ Input stnumarticle.inc Style Title LatexType Command LatexName "!-- --" - LatexParam "2|" + CommandDepth 2 End diff --git a/lib/layouts/docbook-section.layout b/lib/layouts/docbook-section.layout index af744bf697..3c84684a7a 100644 --- a/lib/layouts/docbook-section.layout +++ b/lib/layouts/docbook-section.layout @@ -10,7 +10,7 @@ Input numarticle.inc Style Title LatexType Command LatexName "!-- --" - LatexParam "3|" + CommandDepth 3 End diff --git a/src/ChangeLog b/src/ChangeLog index 8e9465f0b4..100fb7b37a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,19 @@ +2003-11-25 Martin Vermeer + + * src/buffer.C: + * src/lyxlayout.C: + * src/lyxlayout.h: + * src/lyxtext.h: + * src/output_docbook.C: + * src/output_latex.C: + * src/paragraph.C: + * src/paragraph.h: + * src/sgml.C: + * src/sgml.h: + * src/text2.C: Introducing a number of tags parametrizing various + XML formats that we may want to support + 2003-11-25 André Pönitz * InsetList.[Ch] (begein, end): inline as suggested by profiler diff --git a/src/buffer.C b/src/buffer.C index 2cc8444937..ce10f73543 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -16,6 +16,7 @@ #include "buffer_funcs.h" #include "bufferlist.h" #include "bufferparams.h" +#include "counters.h" #include "Bullet.h" #include "Chktex.h" #include "debug.h" @@ -1148,6 +1149,7 @@ void Buffer::makeDocBookFile(string const & fname, ofs << "\n"; + params().getLyXTextClass().counters().reset(); docbookParagraphs(*this, paragraphs(), ofs, runparams); ofs << "\n\n"; diff --git a/src/lyxlayout.C b/src/lyxlayout.C index 79c506831c..4067415a56 100644 --- a/src/lyxlayout.C +++ b/src/lyxlayout.C @@ -82,6 +82,8 @@ enum LayoutTags { LT_TOPSEP, LT_TOCLEVEL, LT_INNERTAG, + LT_LABELTAG, + LT_ITEMTAG, LT_INTITLE // keep this last! }; @@ -145,6 +147,7 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) { "innertag", LT_INNERTAG }, { "intitle", LT_INTITLE }, { "itemsep", LT_ITEMSEP }, + { "itemtag", LT_ITEMTAG }, { "keepempty", LT_KEEPEMPTY }, { "labelbottomsep", LT_LABEL_BOTTOMSEP }, { "labelcounter", LT_LABELCOUNTER }, @@ -153,6 +156,7 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) { "labelsep", LT_LABELSEP }, { "labelstring", LT_LABELSTRING }, { "labelstringappendix", LT_LABELSTRING_APPENDIX }, + { "labeltag", LT_LABELTAG }, { "labeltype", LT_LABELTYPE }, { "latexfooter", LT_LATEXFOOTER }, { "latexheader", LT_LATEXHEADER }, @@ -331,7 +335,7 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) case LT_LATEXPARAM: if (lexrc.next()) - latexparam_ = lexrc.getString(); + latexparam_ = subst(lexrc.getString(), """, "\""); break; case LT_INNERTAG: @@ -339,6 +343,16 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) innertag_ = lexrc.getString(); break; + case LT_LABELTAG: + if (lexrc.next()) + labeltag_ = lexrc.getString(); + break; + + case LT_ITEMTAG: + if (lexrc.next()) + itemtag_ = lexrc.getString(); + break; + case LT_PREAMBLE: preamble_ = lexrc.getLongString("EndPreamble"); break; diff --git a/src/lyxlayout.h b/src/lyxlayout.h index 772d9aeca4..25452e7a0f 100644 --- a/src/lyxlayout.h +++ b/src/lyxlayout.h @@ -65,6 +65,10 @@ public: /// std::string const & innertag() const { return innertag_; } /// + std::string const & labeltag() const { return labeltag_; } + /// + std::string const & itemtag() const { return itemtag_; } + /// std::string const & labelstring_appendix() const { return labelstring_appendix_; } @@ -211,6 +215,10 @@ private: std::string latexparam_; /// Internal tag to use (e.g., for sect header) std::string innertag_; + /// Internal tag to use e.g. to surround varlistentry label) + std::string labeltag_; + /// Internal tag to surround the item text in a list) + std::string itemtag_; /// Macro definitions needed for this layout std::string preamble_; }; diff --git a/src/lyxtext.h b/src/lyxtext.h index 8af10531b3..ba8329128f 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -18,6 +18,7 @@ #include "Bidi.h" #include "layout.h" #include "lyxfont.h" +#include "lyxtextclass.h" #include "ParagraphList_fwd.h" #include "RowList_fwd.h" #include "textcursor.h" @@ -478,4 +479,8 @@ private: /// return the default height of a row in pixels, considering font zoom extern int defaultRowHeight(); +/// +std::string expandLabel(LyXTextClass const & textclass, + LyXLayout_ptr const & layout, bool appendix); + #endif // LYXTEXT_H diff --git a/src/output_docbook.C b/src/output_docbook.C index 047b6a0300..8602b67283 100644 --- a/src/output_docbook.C +++ b/src/output_docbook.C @@ -15,6 +15,8 @@ #include "buffer.h" #include "bufferparams.h" +#include "counters.h" +#include "lyxtext.h" #include "paragraph.h" #include "paragraph_funcs.h" #include "ParagraphParameters.h" @@ -24,6 +26,7 @@ #include "support/lstrings.h" #include "support/lyxlib.h" +#include "support/tostr.h" #include @@ -32,6 +35,7 @@ using lyx::support::atoi; using lyx::support::split; +using lyx::support::subst; using std::endl; using std::ostream; @@ -57,20 +61,21 @@ void docbookParagraphs(Buffer const & buf, string command_name; + string item_tag; + ParagraphList::iterator par = const_cast(paragraphs).begin(); ParagraphList::iterator pend = const_cast(paragraphs).end(); + Counters & counters = buf.params().getLyXTextClass().counters(); + for (; par != pend; ++par) { - string inner_tag; - int desc_on = 0; // description mode LyXLayout_ptr const & style = par->layout(); // environment tag closing for (; depth > par->params().depth(); --depth) { - if (!environment_inner[depth].empty()) sgml::closeEnvTags(os, false, environment_inner[depth], - command_depth + depth); + item_tag, command_depth + depth); sgml::closeTag(os, depth + command_depth, false, environment_stack[depth]); environment_stack[depth].erase(); environment_inner[depth].erase(); @@ -80,19 +85,25 @@ void docbookParagraphs(Buffer const & buf, && environment_stack[depth] != style->latexname() && !environment_stack[depth].empty()) { sgml::closeEnvTags(os, false, environment_inner[depth], - command_depth + depth); + item_tag, command_depth + depth); sgml::closeTag(os, depth + command_depth, false, environment_stack[depth]); environment_stack[depth].erase(); environment_inner[depth].erase(); } - + + string ls = ""; + bool labelid = false; // Write opening SGML tags. - string item_name; switch (style->latextype) { case LATEX_PARAGRAPH: + if (!style->latexparam().empty()) { + counters.step("para"); + int i = counters.value("para"); + ls = "id=\"" + subst(style->latexparam(), "#", tostr(i)) + '"'; + } sgml::openTag(os, depth + command_depth, - false, style->latexname()); + false, style->latexname(), ls); break; case LATEX_COMMAND: @@ -103,7 +114,6 @@ void docbookParagraphs(Buffer const & buf, command_name = style->latexname(); cmd_depth = style->commanddepth; - inner_tag = style->innertag(); if (command_flag) { if (cmd_depth < command_base) { @@ -130,6 +140,9 @@ void docbookParagraphs(Buffer const & buf, command_stack.push_back(string()); command_stack[command_depth] = command_name; + if (!style->latexparam().empty()) { + counters.step(style->counter); + } // treat label as a special case for // more WYSIWYM handling. // This is a hack while paragraphs can't have @@ -141,13 +154,29 @@ void docbookParagraphs(Buffer const & buf, command_name += " id=\""; command_name += (static_cast(inset))->getContents(); command_name += '"'; - desc_on = 3; + labelid = true; + } + } else { + if (!style->latexparam().empty()) { + ls = expandLabel(buf.params().getLyXTextClass(), style, false); + ls = "id=\"" + subst(style->latexparam(), "#", ls) + '"'; } } + + sgml::openTag(os, depth + command_depth, false, command_name, ls); + + // Label around sectioning number: + if (!style->labeltag().empty()) { + sgml::openTag(os, depth + 1 + command_depth, false, + style->labeltag()); + os << expandLabel(buf.params().getLyXTextClass(), style, false); + sgml::closeTag(os, depth + 1 + command_depth, false, + style->labeltag()); + } - sgml::openTag(os, depth + command_depth, false, command_name); // Inner tagged header text, e.g. for sectioning: - sgml::openTag(os, depth + 1 + command_depth, false, inner_tag); + sgml::openTag(os, depth + 1 + command_depth, false, + style->innertag()); break; case LATEX_ENVIRONMENT: @@ -164,31 +193,30 @@ void docbookParagraphs(Buffer const & buf, } environment_stack[depth] = style->latexname(); environment_inner[depth] = "!-- --"; - sgml::openTag(os, depth + command_depth, false, environment_stack[depth]); + // outputs <environment_stack[depth] latexparam()> + sgml::openTag(os, depth + command_depth, false, + environment_stack[depth], style->latexparam()); } else { - sgml::closeEnvTags(os, false, environment_inner[depth], - command_depth + depth); + sgml::closeEnvTags(os, false, environment_inner[depth], + style->itemtag(), command_depth + depth); } if (style->latextype == LATEX_ENVIRONMENT) { - if (!style->latexparam().empty()) { - if (style->latexparam() == "CDATA") + if (!style->innertag().empty()) { + if (style->innertag() == "CDATA") os << "<![CDATA["; else - sgml::openTag(os, depth + command_depth, false, style->latexparam()); + sgml::openTag(os, depth + command_depth, false, + style->innertag()); } break; } - desc_on = (style->labeltype == LABEL_MANUAL); + environment_inner[depth] = style->innertag(); - environment_inner[depth] = desc_on ? "varlistentry" : "listitem"; - sgml::openTag(os, depth + 1 + command_depth, + if (!environment_inner[depth].empty()) + sgml::openTag(os, depth + 1 + command_depth, false, environment_inner[depth]); - - item_name = desc_on ? "term" : "para"; - sgml::openTag(os, depth + 1 + command_depth, - false, item_name); break; default: sgml::openTag(os, depth + command_depth, @@ -196,27 +224,26 @@ void docbookParagraphs(Buffer const & buf, break; } - par->simpleDocBookOnePar(buf, os, outerFont(par, paragraphs), desc_on, - runparams, depth + 1 + command_depth); + par->simpleDocBookOnePar(buf, os, outerFont(par, paragraphs), + runparams, depth + 1 + command_depth, labelid); - string end_tag; // write closing SGML tags switch (style->latextype) { case LATEX_COMMAND: - sgml::closeTag(os, depth + command_depth, false, inner_tag); + sgml::closeTag(os, depth + command_depth, false, + style->innertag()); break; case LATEX_ENVIRONMENT: - if (!style->latexparam().empty()) { - if (style->latexparam() == "CDATA") + if (!style->innertag().empty()) { + if (style->innertag() == "CDATA") os << "]]>"; else - sgml::closeTag(os, depth + command_depth, false, style->latexparam()); + sgml::closeTag(os, depth + command_depth, false, + style->innertag()); } break; case LATEX_ITEM_ENVIRONMENT: - if (desc_on == 1) break; - end_tag = "para"; - sgml::closeTag(os, depth + 1 + command_depth, false, end_tag); + item_tag = style->itemtag(); break; case LATEX_PARAGRAPH: sgml::closeTag(os, depth + command_depth, false, style->latexname()); @@ -231,7 +258,7 @@ void docbookParagraphs(Buffer const & buf, for (int d = depth; d >= 0; --d) { if (!environment_stack[depth].empty()) { sgml::closeEnvTags(os, false, environment_inner[depth], - command_depth + depth); + item_tag, command_depth + depth); } } diff --git a/src/output_latex.C b/src/output_latex.C index 3b6b3449bf..62807cf5aa 100644 --- a/src/output_latex.C +++ b/src/output_latex.C @@ -131,20 +131,14 @@ TeXEnvironment(Buffer const & buf, } if (style->isEnvironment()) { + os << "\\begin{" << style->latexname() << '}'; if (style->latextype == LATEX_LIST_ENVIRONMENT) { - os << "\\begin{" << style->latexname() << "}{" - << pit->params().labelWidthString() << "}\n"; + os << "{" << pit->params().labelWidthString() << "}\n"; } else if (style->labeltype == LABEL_BIBLIO) { // ale970405 - os << "\\begin{" << style->latexname() << "}{" - << bibitemWidest(buf) - << "}\n"; - } else if (style->latextype == LATEX_ITEM_ENVIRONMENT) { - os << "\\begin{" << style->latexname() << '}' - << style->latexparam() << '\n'; + os << "{" << bibitemWidest(buf) << "}\n"; } else - os << "\\begin{" << style->latexname() << '}' - << style->latexparam() << '\n'; + os << style->latexparam() << '\n'; texrow.newline(); } ParagraphList::iterator par = pit; diff --git a/src/paragraph.C b/src/paragraph.C index 35101a0327..0a5efb303a 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -22,6 +22,7 @@ #include "buffer.h" #include "bufferparams.h" +#include "counters.h" #include "encoding.h" #include "debug.h" #include "gettext.h" @@ -39,8 +40,9 @@ #include "insets/insetoptarg.h" #include "support/lstrings.h" -#include "support/textutils.h" #include "support/std_sstream.h" +#include "support/textutils.h" +#include "support/tostr.h" #include <boost/tuple/tuple.hpp> @@ -1329,19 +1331,43 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf, void Paragraph::simpleDocBookOnePar(Buffer const & buf, ostream & os, LyXFont const & outerfont, - int & desc_on, OutputParams const & runparams, - lyx::depth_type depth) const + lyx::depth_type depth, + bool labelid) const { bool emph_flag = false; LyXLayout_ptr const & style = layout(); + LyXLayout_ptr const & defaultstyle + = buf.params().getLyXTextClass().defaultLayout(); LyXFont font_old = (style->labeltype == LABEL_MANUAL ? style->labelfont : style->font); int char_line_count = depth; - //if (!style.free_spacing) - // os << string(depth,' '); + bool label_closed = true; + bool para_closed = true; + + if (style->latextype == LATEX_ITEM_ENVIRONMENT) { + string ls = ""; + Counters & counters = buf.params().getLyXTextClass().counters(); + if (!style->free_spacing) + os << string(depth,' '); + if (!style->labeltag().empty()) { + os << "<" << style->labeltag() << ">\n"; + label_closed = false; + } else { + if (!defaultstyle->latexparam().empty()) { + counters.step("para"); + ls = tostr(counters.value("para")); + ls = " id=\"" + + subst(defaultstyle->latexparam(), "#", ls) + '"'; + } + os << "<" << style->itemtag() << ">\n" + << string(depth, ' ') << "<" + << defaultstyle->latexname() << ls << ">\n"; + para_closed = false; + } + } // parsing main loop for (pos_type i = 0; i < size(); ++i) { @@ -1370,7 +1396,8 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, if (isInset(i)) { InsetOld const * inset = getInset(i); // don't print the inset in position 0 if desc_on == 3 (label) - if (i || desc_on != 3) { + //if (i || desc_on != 3) { + if (!labelid) { if (style->latexparam() == "CDATA") os << "]]>"; inset->docbook(buf, os, runparams); @@ -1387,10 +1414,13 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, os << c; } else if (isFreeSpacing() || c != ' ') { os << str; - } else if (desc_on == 1) { + } else if (!style->labeltag().empty() && !label_closed) { ++char_line_count; - os << "\n</term><listitem><para>"; - desc_on = 2; + os << "\n</" << style->labeltag() << "><" + << style->itemtag() << "><" + << defaultstyle->latexname() << ">"; + label_closed = true; + para_closed = false; } else { os << ' '; } @@ -1407,9 +1437,15 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, } // resets description flag correctly - if (desc_on == 1) { + if (!label_closed) { // <term> not closed... - os << "</term>\n<listitem><para> </para>"; + os << "</" << style->labeltag() << ">\n<" + << style->itemtag() << "><" + << defaultstyle->latexname() << "> "; + } + if (!para_closed) { + os << "\n" << string(depth, ' ') << "</" + << defaultstyle->latexname() << ">\n"; } if (style->free_spacing) os << '\n'; diff --git a/src/paragraph.h b/src/paragraph.h index 6d92ad9c52..fca8d25163 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -129,9 +129,9 @@ public: void simpleDocBookOnePar(Buffer const & buf, std::ostream &, LyXFont const & outerfont, - int & desc_on, OutputParams const & runparams, - lyx::depth_type depth) const; + lyx::depth_type depth, + bool labelid) const; /// bool hasSameLayout(Paragraph const & par) const; diff --git a/src/sgml.C b/src/sgml.C index bd17349760..7ebaf187a6 100644 --- a/src/sgml.C +++ b/src/sgml.C @@ -85,12 +85,16 @@ pair<bool, string> escapeChar(char c) int openTag(ostream & os, Paragraph::depth_type depth, - bool mixcont, string const & latexname) + bool mixcont, string const & latexname, + string const & latexparam) { if (!latexname.empty() && latexname != "!-- --") { if (!mixcont) os << string(depth, ' '); - os << '<' << latexname << '>'; + os << '<' << latexname; + if (!latexparam.empty()) + os << " " << latexparam; + os << '>'; } if (!mixcont) @@ -118,13 +122,13 @@ int closeTag(ostream & os, Paragraph::depth_type depth, unsigned int closeEnvTags(ostream & os, bool mixcont, string const & environment_inner_depth, + string const & itemtag, lyx::depth_type total_depth) { unsigned int lines = 0; if (environment_inner_depth != "!-- --") { - string item_name= "listitem"; - lines += closeTag(os, total_depth, mixcont, item_name); - if (environment_inner_depth == "varlistentry") + lines += closeTag(os, total_depth, mixcont, itemtag); + if (!environment_inner_depth.empty()) lines += closeTag(os, total_depth, mixcont, environment_inner_depth); } diff --git a/src/sgml.h b/src/sgml.h index 9abc886133..d247402f44 100644 --- a/src/sgml.h +++ b/src/sgml.h @@ -29,7 +29,8 @@ std::pair<bool, std::string> escapeChar(char c); /// FIXME int openTag(std::ostream & os, lyx::depth_type depth, - bool mixcont, std::string const & latexname); + bool mixcont, std::string const & latexname, + std::string const & latexparam = std::string()); /// FIXME int closeTag(std::ostream & os, lyx::depth_type depth, @@ -39,6 +40,7 @@ int closeTag(std::ostream & os, lyx::depth_type depth, unsigned int closeEnvTags(std::ostream & os, bool mixcont, std::string const & environment_inner_depth, + std::string const & item_tag, lyx::depth_type total_depth); } diff --git a/src/text2.C b/src/text2.C index 4414a28977..73d96266ee 100644 --- a/src/text2.C +++ b/src/text2.C @@ -724,8 +724,6 @@ void LyXText::setParagraph( } -namespace { - string expandLabel(LyXTextClass const & textclass, LyXLayout_ptr const & layout, bool appendix) { @@ -748,6 +746,8 @@ string expandLabel(LyXTextClass const & textclass, } +namespace { + void incrementItemDepth(ParagraphList::iterator pit, ParagraphList::iterator first_pit) {