[LyX/master] DocBook: fixes in lists.
Thibaut Cuvelier
tcuvelier at lyx.org
Sat Sep 19 18:18:55 UTC 2020
commit 6688b076cc6994b57564ba575d8276bd68f4bd2d
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Sun Aug 30 22:05:40 2020 +0200
DocBook: fixes in lists.
Actually output something when list item is empty. XMLStream discarded the sequence StartTag/EndTag (nothing in between).
New-line behaviour around term in description lists.
---
autotests/export/docbook/Development.xml | 83 +++++++++++++++---------------
lib/layouts/beamer.layout | 1 +
lib/layouts/egs.layout | 1 +
lib/layouts/hollywood.layout | 1 +
lib/layouts/scrclass.inc | 1 +
lib/layouts/svcommon.inc | 1 +
src/output_docbook.cpp | 22 +++++++-
src/xml.cpp | 3 +-
8 files changed, 68 insertions(+), 45 deletions(-)
diff --git a/autotests/export/docbook/Development.xml b/autotests/export/docbook/Development.xml
index d0bc9a4..9ec891d 100644
--- a/autotests/export/docbook/Development.xml
+++ b/autotests/export/docbook/Development.xml
@@ -6,7 +6,7 @@
<subtitle>Version 2.3.x</subtitle>
<section>
<title>File formats</title>
-<section xml:id="sec.When-is-an-0">
+<section xml:id="sec.When-is-an">
<title>When is an update of the .lyx file format number needed?</title>
<para>When you are working on a new feature you may ask yourself whether it needs an update of the .lyx file format number. Whether an update is needed or not is not always obvious. Rule of thumb: </para>
<blockquote>
@@ -17,30 +17,30 @@
<varlistentry>
<term>New document setting</term>
<listitem>
-<para> Whenever you introduce a new setting that is stored in the document header, a file format update is needed.</para>
+<para>Whenever you introduce a new setting that is stored in the document header, a file format update is needed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Removed document setting</term>
<listitem>
-<para> If a certain setting becomes obsolete and gets removed, a file format update is needed.</para>
+<para>If a certain setting becomes obsolete and gets removed, a file format update is needed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>New valid value for an existing setting,</term>
<listitem>
-<para> e. g.</para>
+<para>e. g.</para>
<variablelist>
<varlistentry>
<term>Automatically loaded math package</term>
<listitem>
-<para> The reason for this is that there is no true ERT inset for math formulas: Each command is parsed, and if a user happens to define a local command with the same name as a command that triggers an automatic load of a package, they need to be able to switch off the automatic loading of that package. This switch is stored by the use_package header setting.</para>
+<para>The reason for this is that there is no true ERT inset for math formulas: Each command is parsed, and if a user happens to define a local command with the same name as a command that triggers an automatic load of a package, they need to be able to switch off the automatic loading of that package. This switch is stored by the use_package header setting.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>New language</term>
<listitem>
-<para> that is stored in \language. </para>
+<para>that is stored in \language. </para>
</listitem>
</varlistentry>
</variablelist>
@@ -49,49 +49,49 @@
<varlistentry>
<term>New inset</term>
<listitem>
-<para> Of course a new inset requires a file format update.</para>
+<para>Of course a new inset requires a file format update.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>New style</term>
<listitem>
-<para> If a new style or inset layout is added to any layout file or module shipped with LyX, then a new file format is needed in the master (development) branch. It is possible to backport new styles to the stable version without a file format change.</para>
+<para>If a new style or inset layout is added to any layout file or module shipped with LyX, then a new file format is needed in the master (development) branch. It is possible to backport new styles to the stable version without a file format change.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Removed style</term>
<listitem>
-<para> If a style or inset layout is removed in any layout file or module shipped with LyX, a new file format is required.</para>
+<para>If a style or inset layout is removed in any layout file or module shipped with LyX, a new file format is required.</para>
</listitem>
</varlistentry>
</variablelist>
<para>However, <emphasis role='bold'>new</emphasis> layouts and modules do <emphasis role='bold'>not</emphasis> require a file format update (changed 03/16). </para>
<para>If you are still unsure, please ask on the development list.</para>
-<section xml:id="par.export-test-output-formats-1">
+<section xml:id="par.export-test-output-formats">
<title>Output formats</title>
<para>The following output formats are currently tested for each sample document:</para>
<variablelist>
<varlistentry>
<term>LyX:</term>
<listitem>
-
+<para />
<variablelist>
<varlistentry>
<term>lyx16</term>
<listitem>
-<para> LyX 1.6 file format (lyx2lyx)</para>
+<para>LyX 1.6 file format (lyx2lyx)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>lyx21</term>
<listitem>
-<para> LyX 2.1 file format (lyx2lyx)</para>
+<para>LyX 2.1 file format (lyx2lyx)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>xhtml</term>
<listitem>
-<para> LyXHTML (native LyX HTML export)</para>
+<para>LyXHTML (native LyX HTML export)</para>
</listitem>
</varlistentry>
</variablelist>
@@ -100,54 +100,54 @@
<varlistentry>
<term>LyX + LaTeX:</term>
<listitem>
-
+<para />
<variablelist>
<varlistentry>
<term>dvi</term>
<listitem>
-<para> DVI (8-bit latex)</para>
+<para>DVI (8-bit latex)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>dvi3_texF</term>
<listitem>
-<para> DVI (LuaTeX with 8-bit TeX fonts)</para>
+<para>DVI (LuaTeX with 8-bit TeX fonts)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>dvi3_systemF</term>
<listitem>
-<para> DVI (LuaTeX with Unicode fonts)</para>
+<para>DVI (LuaTeX with Unicode fonts)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pdf2</term>
<listitem>
-<para> PDF (pdflatex)</para>
+<para>PDF (pdflatex)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pdf4_texF</term>
<listitem>
-<para> PDF (XeTeX with 8-bit TeX fonts)</para>
+<para>PDF (XeTeX with 8-bit TeX fonts)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pdf4_systemF</term>
<listitem>
-<para> PDF (XeTeX with Unicode fonts)</para>
+<para>PDF (XeTeX with Unicode fonts)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pdf5_texF</term>
<listitem>
-<para> PDF (LuaTeX with 8-bit TeX fonts)</para>
+<para>PDF (LuaTeX with 8-bit TeX fonts)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pdf5_systemF</term>
<listitem>
-<para> PDF (LuaTeX with Unicode fonts)</para>
+<para>PDF (LuaTeX with Unicode fonts)</para>
</listitem>
</varlistentry>
</variablelist>
@@ -156,18 +156,18 @@
<varlistentry>
<term>LyX + LaTeX + postprocessing:</term>
<listitem>
-
+<para />
<variablelist>
<varlistentry>
<term>pdf</term>
<listitem>
-<para> DVI -> PS (dvips) -> PDF (ps2pdf)</para>
+<para>DVI -> PS (dvips) -> PDF (ps2pdf)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pdf3</term>
<listitem>
-<para> DVI -> PDF (dvipdfm)</para>
+<para>DVI -> PDF (dvipdfm)</para>
</listitem>
</varlistentry>
</variablelist>
@@ -176,90 +176,90 @@
<varlistentry>
<term>not tested:</term>
<listitem>
-<para> (or only if set as default output format in the document source)</para>
+<para>(or only if set as default output format in the document source)</para>
<variablelist>
<varlistentry>
<term>latex</term>
<listitem>
-<para> LaTeX (plain)</para>
+<para>LaTeX (plain)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>luatex</term>
<listitem>
-<para> LaTeX (LuaTeX)</para>
+<para>LaTeX (LuaTeX)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>dviluatex</term>
<listitem>
-<para> LaTeX (dviluatex)</para>
+<para>LaTeX (dviluatex)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pdflatex</term>
<listitem>
-<para> LaTeX (pdflatex)</para>
+<para>LaTeX (pdflatex)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>platex</term>
<listitem>
-<para> LaTeX (pLaTeX)</para>
+<para>LaTeX (pLaTeX)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>xetex</term>
<listitem>
-<para> LaTeX (XeTeX) </para>
+<para>LaTeX (XeTeX) </para>
</listitem>
</varlistentry>
<varlistentry>
<term>eps3</term>
<listitem>
-<para> EPS (encapsulated Postscript) (cropped)</para>
+<para>EPS (encapsulated Postscript) (cropped)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>ps</term>
<listitem>
-<para> DVI -> Postscript (dvips)</para>
+<para>DVI -> Postscript (dvips)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>odf</term>
<listitem>
-<para> </para>
+<para />
</listitem>
</varlistentry>
<varlistentry>
<term>text</term>
<listitem>
-<para> (nor text2, ..., text4)</para>
+<para>(nor text2, ..., text4)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>textparagraph</term>
<listitem>
-<para> </para>
+<para />
</listitem>
</varlistentry>
<varlistentry>
<term>word</term>
<listitem>
-<para> </para>
+<para />
</listitem>
</varlistentry>
<varlistentry>
<term>word2</term>
<listitem>
-<para> </para>
+<para />
</listitem>
</varlistentry>
<varlistentry>
<term>wordhtml</term>
<listitem>
-<para> </para>
+<para />
</listitem>
</varlistentry>
</variablelist>
@@ -269,5 +269,4 @@
</section>
</section>
</section>
-
</article>
\ No newline at end of file
diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout
index b316b14..f6d17c3 100644
--- a/lib/layouts/beamer.layout
+++ b/lib/layouts/beamer.layout
@@ -234,6 +234,7 @@ Style Description
DocBookItemTag listitem
DocBookItemInnerTag para
DocBookItemLabelTag term
+ DocBookItemLabelTagType paragraph
End
diff --git a/lib/layouts/egs.layout b/lib/layouts/egs.layout
index 0298b69..6ee01ed 100644
--- a/lib/layouts/egs.layout
+++ b/lib/layouts/egs.layout
@@ -269,6 +269,7 @@ Style Description
DocBookItemTag listitem
DocBookItemInnerTag para
DocBookItemLabelTag term
+ DocBookItemLabelTagType paragraph
End
diff --git a/lib/layouts/hollywood.layout b/lib/layouts/hollywood.layout
index 38767c4..7d10bb9 100644
--- a/lib/layouts/hollywood.layout
+++ b/lib/layouts/hollywood.layout
@@ -142,6 +142,7 @@ Style Description
DocBookItemTag listitem
DocBookItemInnerTag para
DocBookItemLabelTag term
+ DocBookItemLabelTagType paragraph
End
diff --git a/lib/layouts/scrclass.inc b/lib/layouts/scrclass.inc
index 1a41a4d..9524ec0 100644
--- a/lib/layouts/scrclass.inc
+++ b/lib/layouts/scrclass.inc
@@ -69,6 +69,7 @@ Style Labeling
DocBookItemTag listitem
DocBookItemInnerTag para
DocBookItemLabelTag term
+ DocBookItemLabelTagType paragraph
End
Input stdsections.inc
diff --git a/lib/layouts/svcommon.inc b/lib/layouts/svcommon.inc
index 57573cc..67ed799 100644
--- a/lib/layouts/svcommon.inc
+++ b/lib/layouts/svcommon.inc
@@ -620,6 +620,7 @@ Style Description
DocBookItemTag listitem
DocBookItemInnerTag para
DocBookItemLabelTag term
+ DocBookItemLabelTagType paragraph
End
Style Petit
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index cf76bf4..d672144 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -255,6 +255,25 @@ void closeTag(XMLStream & xs, const std::string & tag, const std::string & tagty
}
+void compTag(XMLStream & xs, const std::string & tag, const std::string & attr, const std::string & tagtype)
+{
+ if (tag.empty() || tag == "NONE")
+ return;
+
+ // Special case for <para>: always considered as a paragraph.
+ if (tag == "para" || tagtype == "paragraph" || tagtype == "block") {
+ if (!xs.isLastTagCR())
+ xs << xml::CR();
+ xs << xml::CompTag(tag, attr);
+ xs << xml::CR();
+ } else if (tagtype == "inline") {
+ xs << xml::CompTag(tag, attr);
+ } else {
+ xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + tag + "'");
+ }
+}
+
+
// Higher-level convenience functions.
void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar)
@@ -692,9 +711,8 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text,
}
} else {
// DocBook doesn't like emptiness.
- openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(),
+ compTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(),
par->layout().docbookiteminnertagtype());
- closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype());
}
// If the next item is deeper, it must go entirely within this item (do it recursively).
diff --git a/src/xml.cpp b/src/xml.cpp
index 557bb01..150f4c5 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -651,7 +651,8 @@ docstring xml::cleanID(docstring const & orig)
// as both of them would be transformed as "a.b". With this procedure, one will become "a.b" and the other "a.b-1".
if (mangle && mangledNames.find(content) != mangledNames.end()) {
int & mangleID = tMangleID.localData();
- content += "-" + convert<docstring>(mangleID);
+ if (mangleID > 0)
+ content += "-" + convert<docstring>(mangleID);
mangleID += 1;
}
More information about the lyx-cvs
mailing list