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
This commit is contained in:
Martin Vermeer 2003-11-25 17:23:36 +00:00
parent 1dc2202e8b
commit af37f0d23e
28 changed files with 479 additions and 85 deletions

View File

@ -1,3 +1,23 @@
2003-11-25 Martin Vermeer <martin.vermeer@hut.fi>
* 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 <roman.maurer@amis.net> 2003-11-17 Roman Maurer <roman.maurer@amis.net>
* examples/sl_splash.lyx: update * examples/sl_splash.lyx: update

View File

@ -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 <jamatos@lyx.org>
# Martin Vermeer <martin.vermeer@hut.fi>
Input agu_stdclass.inc
Input numarticle.inc
# Exclude higher, or equal, sections:
NoStyle Part
NoStyle Chapter

View File

@ -0,0 +1,89 @@
# Textclass definition file for AGU-Article.
# Author : José Abílio Oliveira Matos <jamatos@lyx.org>
# Martin Vermeer <martin.vermeer@hut.fi>
# 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

View File

@ -0,0 +1,34 @@
# Author : José Matos <jamatos@lyx.org>
# Martin Vermeer <martin.vermeer@hut.fi>
# 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

View File

@ -0,0 +1,37 @@
# Textclass definition file for AGU-Article.
# Author : José Abílio Oliveira Matos <jamatos@lyx.org>
# Martin Vermeer <martin.vermeer@hut.fi>
# 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=&quot;bulleted&quot;"
ItemTag item
End
Style Enumerate
LatexType Item_Environment
LatexName lst
Latexparam "type=&quot;ordered&quot;"
ItemTag item
End
Style Description
LatexType Item_environment
LatexName lst
Latexparam "type=&quot;unordered&quot;"
ItemTag item
End
# maybe List is the same as simplelist (I need to check it).
NoStyle List

View File

@ -0,0 +1,86 @@
# Textclass definition file for docbook.
# Author : José Abílio Oliveira Matos <jamatos@lyx.org>
# Martin Vermeer <martin.vermeer@hut.fi>
# 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

View File

@ -2,7 +2,7 @@
# Author : José Abílio Oliveira Matos <jamatos@lyx.org> # Author : José Abílio Oliveira Matos <jamatos@lyx.org>
# This is the counterpart of lyxmacros.inc # 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. # related layouts in latex and docbook.
Input lyxmacros.inc Input lyxmacros.inc
@ -11,7 +11,7 @@ Style Code
CopyStyle LyX-Code CopyStyle LyX-Code
LatexType Environment LatexType Environment
LatexName programlisting LatexName programlisting
LatexParam CDATA InnerTag CDATA
PassThru 1 PassThru 1
End End

View File

@ -2,7 +2,7 @@
# Author : José Abílio Oliveira Matos <jamatos@lyx.org> # Author : José Abílio Oliveira Matos <jamatos@lyx.org>
# This file is the counterpart of stdclass.inc # 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. # related layouts in latex and docbook.
OutputType docbook OutputType docbook
@ -38,7 +38,7 @@ CharStyle Filename
EndFont EndFont
End End
CharStyle FirstName CharStyle Firstname
LatexType Command LatexType Command
LatexName firstname LatexName firstname
Font Font

View File

@ -2,7 +2,7 @@
# Author : José Abílio Oliveira Matos <jamatos@lyx.org> # Author : José Abílio Oliveira Matos <jamatos@lyx.org>
# This is the counterpart of stdlayouts.inc # 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. # related layouts in latex and docbook.
Input stdlayouts.inc Input stdlayouts.inc
@ -34,7 +34,7 @@ End
Style Quotation Style Quotation
LatexType Environment LatexType Environment
LatexName blockquote LatexName blockquote
LatexParam para InnerTag para
End End
# Quote should be an inline element # Quote should be an inline element

View File

@ -2,7 +2,7 @@
# Author : José Abílio Oliveira Matos <jamatos@lyx.org> # Author : José Abílio Oliveira Matos <jamatos@lyx.org>
# This is the counterpart of stdlists.inc # 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. # related layouts in latex and docbook.
Input stdlists.inc Input stdlists.inc
@ -11,18 +11,23 @@ Input stdlists.inc
Style Itemize Style Itemize
LatexType Item_Environment LatexType Item_Environment
LatexName itemizedlist LatexName itemizedlist
ItemTag listitem
End End
Style Enumerate Style Enumerate
LatexType Item_Environment LatexType Item_Environment
LatexName orderedlist LatexName orderedlist
ItemTag listitem
End End
Style Description Style Description
LatexType Item_environment LatexType Item_environment
LatexName variablelist LatexName variablelist
InnerTag varlistentry
LabelTag term
ItemTag listitem
End End
# maybe List is the same as simplelist (I need to check it). # maybe List is the same as simplelist (I need to check it).

View File

@ -2,7 +2,7 @@
# Author : José Abílio Oliveira Matos <jamatos@lyx.org> # Author : José Abílio Oliveira Matos <jamatos@lyx.org>
# This file is the counterpart of stdstarsections.inc # 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. # related layouts in latex and docbook.
# empty for now, it is possible to do it using bridgehead with attribute # empty for now, it is possible to do it using bridgehead with attribute

View File

@ -2,7 +2,7 @@
# Author : José Abílio Oliveira Matos <jamatos@lyx.org> # Author : José Abílio Oliveira Matos <jamatos@lyx.org>
# This file is the counterpart of stdstruct.inc # 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. # related layouts in latex and docbook.
Input stdstruct.inc Input stdstruct.inc
@ -10,7 +10,7 @@ Input stdstruct.inc
Style Abstract Style Abstract
LatexType Environment LatexType Environment
LatexName abstract LatexName abstract
LatexParam para InnerTag para
End End
NoStyle Bibliography NoStyle Bibliography

View File

@ -13,7 +13,7 @@ Style Title
LatexType Command LatexType Command
LatexName articleinfo LatexName articleinfo
CommandDepth 2 CommandDepth 2
InnerTag "title" InnerTag title
End End
@ -28,7 +28,7 @@ Style Authorgroup
CopyStyle Author CopyStyle Author
LatexType Environment LatexType Environment
LatexName authorgroup LatexName authorgroup
LatexParam author InnerTag author
End End
@ -68,7 +68,8 @@ Style RevisionHistory
Margin Static Margin Static
LatexType Command LatexType Command
LatexName revhistory LatexName revhistory
LatexParam "3|!-- --" CommandDepth 3
InnerTag "!-- --"
LeftMargin MMM LeftMargin MMM
RightMargin MMM RightMargin MMM
ParIndent MM ParIndent MM
@ -88,7 +89,8 @@ Style Revision
Margin Dynamic Margin Dynamic
LatexType Command LatexType Command
LatexName revision LatexName revision
LatexParam "4|revnumber" CommandDepth 4
InnerTag revnumber
LabelSep xxx LabelSep xxx
ParSkip 0.4 ParSkip 0.4
TopSep 0.9 TopSep 0.9

View File

@ -11,5 +11,5 @@ Input report
Style Title Style Title
LatexType Command LatexType Command
LatexName bookinfo LatexName bookinfo
LatexParam "1|" CommandDepth 1
End End

View File

@ -10,7 +10,7 @@ Input stnumarticle.inc
Style Title Style Title
LatexType Command LatexType Command
LatexName "!-- --" LatexName "!-- --"
LatexParam "2|" CommandDepth 2
End End

View File

@ -10,7 +10,7 @@ Input numarticle.inc
Style Title Style Title
LatexType Command LatexType Command
LatexName "!-- --" LatexName "!-- --"
LatexParam "3|" CommandDepth 3
End End

View File

@ -1,4 +1,19 @@
2003-11-25 Martin Vermeer <martin.vermeer@hut.fi>
* 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 <poenitz@gmx.net> 2003-11-25 André Pönitz <poenitz@gmx.net>
* InsetList.[Ch] (begein, end): inline as suggested by profiler * InsetList.[Ch] (begein, end): inline as suggested by profiler

View File

@ -16,6 +16,7 @@
#include "buffer_funcs.h" #include "buffer_funcs.h"
#include "bufferlist.h" #include "bufferlist.h"
#include "bufferparams.h" #include "bufferparams.h"
#include "counters.h"
#include "Bullet.h" #include "Bullet.h"
#include "Chktex.h" #include "Chktex.h"
#include "debug.h" #include "debug.h"
@ -1148,6 +1149,7 @@ void Buffer::makeDocBookFile(string const & fname,
ofs << "<!-- DocBook file was created by LyX " << lyx_version ofs << "<!-- DocBook file was created by LyX " << lyx_version
<< "\n See http://www.lyx.org/ for more information -->\n"; << "\n See http://www.lyx.org/ for more information -->\n";
params().getLyXTextClass().counters().reset();
docbookParagraphs(*this, paragraphs(), ofs, runparams); docbookParagraphs(*this, paragraphs(), ofs, runparams);
ofs << "\n\n"; ofs << "\n\n";

View File

@ -82,6 +82,8 @@ enum LayoutTags {
LT_TOPSEP, LT_TOPSEP,
LT_TOCLEVEL, LT_TOCLEVEL,
LT_INNERTAG, LT_INNERTAG,
LT_LABELTAG,
LT_ITEMTAG,
LT_INTITLE // keep this last! LT_INTITLE // keep this last!
}; };
@ -145,6 +147,7 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass)
{ "innertag", LT_INNERTAG }, { "innertag", LT_INNERTAG },
{ "intitle", LT_INTITLE }, { "intitle", LT_INTITLE },
{ "itemsep", LT_ITEMSEP }, { "itemsep", LT_ITEMSEP },
{ "itemtag", LT_ITEMTAG },
{ "keepempty", LT_KEEPEMPTY }, { "keepempty", LT_KEEPEMPTY },
{ "labelbottomsep", LT_LABEL_BOTTOMSEP }, { "labelbottomsep", LT_LABEL_BOTTOMSEP },
{ "labelcounter", LT_LABELCOUNTER }, { "labelcounter", LT_LABELCOUNTER },
@ -153,6 +156,7 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass)
{ "labelsep", LT_LABELSEP }, { "labelsep", LT_LABELSEP },
{ "labelstring", LT_LABELSTRING }, { "labelstring", LT_LABELSTRING },
{ "labelstringappendix", LT_LABELSTRING_APPENDIX }, { "labelstringappendix", LT_LABELSTRING_APPENDIX },
{ "labeltag", LT_LABELTAG },
{ "labeltype", LT_LABELTYPE }, { "labeltype", LT_LABELTYPE },
{ "latexfooter", LT_LATEXFOOTER }, { "latexfooter", LT_LATEXFOOTER },
{ "latexheader", LT_LATEXHEADER }, { "latexheader", LT_LATEXHEADER },
@ -331,7 +335,7 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass)
case LT_LATEXPARAM: case LT_LATEXPARAM:
if (lexrc.next()) if (lexrc.next())
latexparam_ = lexrc.getString(); latexparam_ = subst(lexrc.getString(), "&quot;", "\"");
break; break;
case LT_INNERTAG: case LT_INNERTAG:
@ -339,6 +343,16 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass)
innertag_ = lexrc.getString(); innertag_ = lexrc.getString();
break; break;
case LT_LABELTAG:
if (lexrc.next())
labeltag_ = lexrc.getString();
break;
case LT_ITEMTAG:
if (lexrc.next())
itemtag_ = lexrc.getString();
break;
case LT_PREAMBLE: case LT_PREAMBLE:
preamble_ = lexrc.getLongString("EndPreamble"); preamble_ = lexrc.getLongString("EndPreamble");
break; break;

View File

@ -65,6 +65,10 @@ public:
/// ///
std::string const & innertag() const { return innertag_; } 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 { std::string const & labelstring_appendix() const {
return labelstring_appendix_; return labelstring_appendix_;
} }
@ -211,6 +215,10 @@ private:
std::string latexparam_; std::string latexparam_;
/// Internal tag to use (e.g., <title></title> for sect header) /// Internal tag to use (e.g., <title></title> for sect header)
std::string innertag_; 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 /// Macro definitions needed for this layout
std::string preamble_; std::string preamble_;
}; };

View File

@ -18,6 +18,7 @@
#include "Bidi.h" #include "Bidi.h"
#include "layout.h" #include "layout.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "lyxtextclass.h"
#include "ParagraphList_fwd.h" #include "ParagraphList_fwd.h"
#include "RowList_fwd.h" #include "RowList_fwd.h"
#include "textcursor.h" #include "textcursor.h"
@ -478,4 +479,8 @@ private:
/// return the default height of a row in pixels, considering font zoom /// return the default height of a row in pixels, considering font zoom
extern int defaultRowHeight(); extern int defaultRowHeight();
///
std::string expandLabel(LyXTextClass const & textclass,
LyXLayout_ptr const & layout, bool appendix);
#endif // LYXTEXT_H #endif // LYXTEXT_H

View File

@ -15,6 +15,8 @@
#include "buffer.h" #include "buffer.h"
#include "bufferparams.h" #include "bufferparams.h"
#include "counters.h"
#include "lyxtext.h"
#include "paragraph.h" #include "paragraph.h"
#include "paragraph_funcs.h" #include "paragraph_funcs.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
@ -24,6 +26,7 @@
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include "support/tostr.h"
#include <stack> #include <stack>
@ -32,6 +35,7 @@
using lyx::support::atoi; using lyx::support::atoi;
using lyx::support::split; using lyx::support::split;
using lyx::support::subst;
using std::endl; using std::endl;
using std::ostream; using std::ostream;
@ -57,20 +61,21 @@ void docbookParagraphs(Buffer const & buf,
string command_name; string command_name;
string item_tag;
ParagraphList::iterator par = const_cast<ParagraphList&>(paragraphs).begin(); ParagraphList::iterator par = const_cast<ParagraphList&>(paragraphs).begin();
ParagraphList::iterator pend = const_cast<ParagraphList&>(paragraphs).end(); ParagraphList::iterator pend = const_cast<ParagraphList&>(paragraphs).end();
Counters & counters = buf.params().getLyXTextClass().counters();
for (; par != pend; ++par) { for (; par != pend; ++par) {
string inner_tag;
int desc_on = 0; // description mode
LyXLayout_ptr const & style = par->layout(); LyXLayout_ptr const & style = par->layout();
// environment tag closing // environment tag closing
for (; depth > par->params().depth(); --depth) { for (; depth > par->params().depth(); --depth) {
if (!environment_inner[depth].empty())
sgml::closeEnvTags(os, false, environment_inner[depth], 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]); sgml::closeTag(os, depth + command_depth, false, environment_stack[depth]);
environment_stack[depth].erase(); environment_stack[depth].erase();
environment_inner[depth].erase(); environment_inner[depth].erase();
@ -80,19 +85,25 @@ void docbookParagraphs(Buffer const & buf,
&& environment_stack[depth] != style->latexname() && environment_stack[depth] != style->latexname()
&& !environment_stack[depth].empty()) { && !environment_stack[depth].empty()) {
sgml::closeEnvTags(os, false, environment_inner[depth], 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]); sgml::closeTag(os, depth + command_depth, false, environment_stack[depth]);
environment_stack[depth].erase(); environment_stack[depth].erase();
environment_inner[depth].erase(); environment_inner[depth].erase();
} }
string ls = "";
bool labelid = false;
// Write opening SGML tags. // Write opening SGML tags.
string item_name;
switch (style->latextype) { switch (style->latextype) {
case LATEX_PARAGRAPH: 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, sgml::openTag(os, depth + command_depth,
false, style->latexname()); false, style->latexname(), ls);
break; break;
case LATEX_COMMAND: case LATEX_COMMAND:
@ -103,7 +114,6 @@ void docbookParagraphs(Buffer const & buf,
command_name = style->latexname(); command_name = style->latexname();
cmd_depth = style->commanddepth; cmd_depth = style->commanddepth;
inner_tag = style->innertag();
if (command_flag) { if (command_flag) {
if (cmd_depth < command_base) { if (cmd_depth < command_base) {
@ -130,6 +140,9 @@ void docbookParagraphs(Buffer const & buf,
command_stack.push_back(string()); command_stack.push_back(string());
command_stack[command_depth] = command_name; command_stack[command_depth] = command_name;
if (!style->latexparam().empty()) {
counters.step(style->counter);
}
// treat label as a special case for // treat label as a special case for
// more WYSIWYM handling. // more WYSIWYM handling.
// This is a hack while paragraphs can't have // This is a hack while paragraphs can't have
@ -141,13 +154,29 @@ void docbookParagraphs(Buffer const & buf,
command_name += " id=\""; command_name += " id=\"";
command_name += (static_cast<InsetCommand *>(inset))->getContents(); command_name += (static_cast<InsetCommand *>(inset))->getContents();
command_name += '"'; 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. <title> for sectioning: // Inner tagged header text, e.g. <title> for sectioning:
sgml::openTag(os, depth + 1 + command_depth, false, inner_tag); sgml::openTag(os, depth + 1 + command_depth, false,
style->innertag());
break; break;
case LATEX_ENVIRONMENT: case LATEX_ENVIRONMENT:
@ -164,31 +193,30 @@ void docbookParagraphs(Buffer const & buf,
} }
environment_stack[depth] = style->latexname(); environment_stack[depth] = style->latexname();
environment_inner[depth] = "!-- --"; 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 { } else {
sgml::closeEnvTags(os, false, environment_inner[depth], sgml::closeEnvTags(os, false, environment_inner[depth],
command_depth + depth); style->itemtag(), command_depth + depth);
} }
if (style->latextype == LATEX_ENVIRONMENT) { if (style->latextype == LATEX_ENVIRONMENT) {
if (!style->latexparam().empty()) { if (!style->innertag().empty()) {
if (style->latexparam() == "CDATA") if (style->innertag() == "CDATA")
os << "<![CDATA["; os << "<![CDATA[";
else else
sgml::openTag(os, depth + command_depth, false, style->latexparam()); sgml::openTag(os, depth + command_depth, false,
style->innertag());
} }
break; break;
} }
desc_on = (style->labeltype == LABEL_MANUAL); environment_inner[depth] = style->innertag();
environment_inner[depth] = desc_on ? "varlistentry" : "listitem"; if (!environment_inner[depth].empty())
sgml::openTag(os, depth + 1 + command_depth, sgml::openTag(os, depth + 1 + command_depth,
false, environment_inner[depth]); false, environment_inner[depth]);
item_name = desc_on ? "term" : "para";
sgml::openTag(os, depth + 1 + command_depth,
false, item_name);
break; break;
default: default:
sgml::openTag(os, depth + command_depth, sgml::openTag(os, depth + command_depth,
@ -196,27 +224,26 @@ void docbookParagraphs(Buffer const & buf,
break; break;
} }
par->simpleDocBookOnePar(buf, os, outerFont(par, paragraphs), desc_on, par->simpleDocBookOnePar(buf, os, outerFont(par, paragraphs),
runparams, depth + 1 + command_depth); runparams, depth + 1 + command_depth, labelid);
string end_tag;
// write closing SGML tags // write closing SGML tags
switch (style->latextype) { switch (style->latextype) {
case LATEX_COMMAND: case LATEX_COMMAND:
sgml::closeTag(os, depth + command_depth, false, inner_tag); sgml::closeTag(os, depth + command_depth, false,
style->innertag());
break; break;
case LATEX_ENVIRONMENT: case LATEX_ENVIRONMENT:
if (!style->latexparam().empty()) { if (!style->innertag().empty()) {
if (style->latexparam() == "CDATA") if (style->innertag() == "CDATA")
os << "]]>"; os << "]]>";
else else
sgml::closeTag(os, depth + command_depth, false, style->latexparam()); sgml::closeTag(os, depth + command_depth, false,
style->innertag());
} }
break; break;
case LATEX_ITEM_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT:
if (desc_on == 1) break; item_tag = style->itemtag();
end_tag = "para";
sgml::closeTag(os, depth + 1 + command_depth, false, end_tag);
break; break;
case LATEX_PARAGRAPH: case LATEX_PARAGRAPH:
sgml::closeTag(os, depth + command_depth, false, style->latexname()); 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) { for (int d = depth; d >= 0; --d) {
if (!environment_stack[depth].empty()) { if (!environment_stack[depth].empty()) {
sgml::closeEnvTags(os, false, environment_inner[depth], sgml::closeEnvTags(os, false, environment_inner[depth],
command_depth + depth); item_tag, command_depth + depth);
} }
} }

View File

@ -131,20 +131,14 @@ TeXEnvironment(Buffer const & buf,
} }
if (style->isEnvironment()) { if (style->isEnvironment()) {
os << "\\begin{" << style->latexname() << '}';
if (style->latextype == LATEX_LIST_ENVIRONMENT) { if (style->latextype == LATEX_LIST_ENVIRONMENT) {
os << "\\begin{" << style->latexname() << "}{" os << "{" << pit->params().labelWidthString() << "}\n";
<< pit->params().labelWidthString() << "}\n";
} else if (style->labeltype == LABEL_BIBLIO) { } else if (style->labeltype == LABEL_BIBLIO) {
// ale970405 // ale970405
os << "\\begin{" << style->latexname() << "}{" os << "{" << bibitemWidest(buf) << "}\n";
<< bibitemWidest(buf)
<< "}\n";
} else if (style->latextype == LATEX_ITEM_ENVIRONMENT) {
os << "\\begin{" << style->latexname() << '}'
<< style->latexparam() << '\n';
} else } else
os << "\\begin{" << style->latexname() << '}' os << style->latexparam() << '\n';
<< style->latexparam() << '\n';
texrow.newline(); texrow.newline();
} }
ParagraphList::iterator par = pit; ParagraphList::iterator par = pit;

View File

@ -22,6 +22,7 @@
#include "buffer.h" #include "buffer.h"
#include "bufferparams.h" #include "bufferparams.h"
#include "counters.h"
#include "encoding.h" #include "encoding.h"
#include "debug.h" #include "debug.h"
#include "gettext.h" #include "gettext.h"
@ -39,8 +40,9 @@
#include "insets/insetoptarg.h" #include "insets/insetoptarg.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/textutils.h"
#include "support/std_sstream.h" #include "support/std_sstream.h"
#include "support/textutils.h"
#include "support/tostr.h"
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
@ -1329,19 +1331,43 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf,
void Paragraph::simpleDocBookOnePar(Buffer const & buf, void Paragraph::simpleDocBookOnePar(Buffer const & buf,
ostream & os, ostream & os,
LyXFont const & outerfont, LyXFont const & outerfont,
int & desc_on,
OutputParams const & runparams, OutputParams const & runparams,
lyx::depth_type depth) const lyx::depth_type depth,
bool labelid) const
{ {
bool emph_flag = false; bool emph_flag = false;
LyXLayout_ptr const & style = layout(); LyXLayout_ptr const & style = layout();
LyXLayout_ptr const & defaultstyle
= buf.params().getLyXTextClass().defaultLayout();
LyXFont font_old = (style->labeltype == LABEL_MANUAL ? style->labelfont : style->font); LyXFont font_old = (style->labeltype == LABEL_MANUAL ? style->labelfont : style->font);
int char_line_count = depth; int char_line_count = depth;
//if (!style.free_spacing) bool label_closed = true;
// os << string(depth,' '); 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 // parsing main loop
for (pos_type i = 0; i < size(); ++i) { for (pos_type i = 0; i < size(); ++i) {
@ -1370,7 +1396,8 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
if (isInset(i)) { if (isInset(i)) {
InsetOld const * inset = getInset(i); InsetOld const * inset = getInset(i);
// don't print the inset in position 0 if desc_on == 3 (label) // 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") if (style->latexparam() == "CDATA")
os << "]]>"; os << "]]>";
inset->docbook(buf, os, runparams); inset->docbook(buf, os, runparams);
@ -1387,10 +1414,13 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
os << c; os << c;
} else if (isFreeSpacing() || c != ' ') { } else if (isFreeSpacing() || c != ' ') {
os << str; os << str;
} else if (desc_on == 1) { } else if (!style->labeltag().empty() && !label_closed) {
++char_line_count; ++char_line_count;
os << "\n</term><listitem><para>"; os << "\n</" << style->labeltag() << "><"
desc_on = 2; << style->itemtag() << "><"
<< defaultstyle->latexname() << ">";
label_closed = true;
para_closed = false;
} else { } else {
os << ' '; os << ' ';
} }
@ -1407,9 +1437,15 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
} }
// resets description flag correctly // resets description flag correctly
if (desc_on == 1) { if (!label_closed) {
// <term> not closed... // <term> not closed...
os << "</term>\n<listitem><para>&nbsp;</para>"; os << "</" << style->labeltag() << ">\n<"
<< style->itemtag() << "><"
<< defaultstyle->latexname() << ">&nbsp;";
}
if (!para_closed) {
os << "\n" << string(depth, ' ') << "</"
<< defaultstyle->latexname() << ">\n";
} }
if (style->free_spacing) if (style->free_spacing)
os << '\n'; os << '\n';

View File

@ -129,9 +129,9 @@ public:
void simpleDocBookOnePar(Buffer const & buf, void simpleDocBookOnePar(Buffer const & buf,
std::ostream &, std::ostream &,
LyXFont const & outerfont, LyXFont const & outerfont,
int & desc_on,
OutputParams const & runparams, OutputParams const & runparams,
lyx::depth_type depth) const; lyx::depth_type depth,
bool labelid) const;
/// ///
bool hasSameLayout(Paragraph const & par) const; bool hasSameLayout(Paragraph const & par) const;

View File

@ -85,12 +85,16 @@ pair<bool, string> escapeChar(char c)
int openTag(ostream & os, Paragraph::depth_type depth, 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 (!latexname.empty() && latexname != "!-- --") {
if (!mixcont) if (!mixcont)
os << string(depth, ' '); os << string(depth, ' ');
os << '<' << latexname << '>'; os << '<' << latexname;
if (!latexparam.empty())
os << " " << latexparam;
os << '>';
} }
if (!mixcont) if (!mixcont)
@ -118,13 +122,13 @@ int closeTag(ostream & os, Paragraph::depth_type depth,
unsigned int closeEnvTags(ostream & os, bool mixcont, unsigned int closeEnvTags(ostream & os, bool mixcont,
string const & environment_inner_depth, string const & environment_inner_depth,
string const & itemtag,
lyx::depth_type total_depth) lyx::depth_type total_depth)
{ {
unsigned int lines = 0; unsigned int lines = 0;
if (environment_inner_depth != "!-- --") { if (environment_inner_depth != "!-- --") {
string item_name= "listitem"; lines += closeTag(os, total_depth, mixcont, itemtag);
lines += closeTag(os, total_depth, mixcont, item_name); if (!environment_inner_depth.empty())
if (environment_inner_depth == "varlistentry")
lines += closeTag(os, total_depth, mixcont, lines += closeTag(os, total_depth, mixcont,
environment_inner_depth); environment_inner_depth);
} }

View File

@ -29,7 +29,8 @@ std::pair<bool, std::string> escapeChar(char c);
/// FIXME /// FIXME
int openTag(std::ostream & os, lyx::depth_type depth, 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 /// FIXME
int closeTag(std::ostream & os, lyx::depth_type depth, 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, unsigned int closeEnvTags(std::ostream & os,
bool mixcont, bool mixcont,
std::string const & environment_inner_depth, std::string const & environment_inner_depth,
std::string const & item_tag,
lyx::depth_type total_depth); lyx::depth_type total_depth);
} }

View File

@ -724,8 +724,6 @@ void LyXText::setParagraph(
} }
namespace {
string expandLabel(LyXTextClass const & textclass, string expandLabel(LyXTextClass const & textclass,
LyXLayout_ptr const & layout, bool appendix) LyXLayout_ptr const & layout, bool appendix)
{ {
@ -748,6 +746,8 @@ string expandLabel(LyXTextClass const & textclass,
} }
namespace {
void incrementItemDepth(ParagraphList::iterator pit, void incrementItemDepth(ParagraphList::iterator pit,
ParagraphList::iterator first_pit) ParagraphList::iterator first_pit)
{ {