[LyX/master] DocBook: fix issues with nested description lists.

Thibaut Cuvelier tcuvelier at lyx.org
Sat Jul 25 21:26:43 UTC 2020


commit 88e00a0b7b66758ba1ce47d5e306be15223cf78b
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Jul 25 23:51:32 2020 +0200

    DocBook: fix issues with nested description lists.
---
 .../export/docbook/description_list_nested.lyx     |  179 ++++++++++++++++++++
 .../export/docbook/description_list_nested.xml     |   39 +++++
 autotests/export/docbook/lists.xml                 |    4 +-
 src/output_docbook.cpp                             |   14 +-
 4 files changed, 230 insertions(+), 6 deletions(-)

diff --git a/autotests/export/docbook/description_list_nested.lyx b/autotests/export/docbook/description_list_nested.lyx
new file mode 100644
index 0000000..9ec514e
--- /dev/null
+++ b/autotests/export/docbook/description_list_nested.lyx
@@ -0,0 +1,179 @@
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 598
+\begin_document
+\begin_header
+\save_transient_properties true
+\origin unavailable
+\textclass scrartcl
+\options BCOR8mm,captions=tableheading
+\use_default_options false
+\begin_modules
+logicalmkup
+\end_modules
+\maintain_unincluded_children no
+\language english
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "lmodern" "default"
+\font_sans "lmss" "default"
+\font_typewriter "lmtt" "default"
+\font_math "auto" "auto"
+\font_default_family default
+\use_non_tex_fonts false
+\font_sc false
+\font_roman_osf false
+\font_sans_osf false
+\font_typewriter_osf false
+\font_sf_scale 100 100
+\font_tt_scale 100 100
+\use_microtype false
+\use_dash_ligatures true
+\graphics default
+\default_output_format pdf2
+\output_sync 1
+\bibtex_command default
+\index_command default
+\paperfontsize 12
+\spacing single
+\use_hyperref true
+\pdf_title "LyX's Development manual"
+\pdf_author "LyX Team"
+\pdf_subject "LyX's development documentation"
+\pdf_keywords "LyX, Documentation, Development"
+\pdf_bookmarks true
+\pdf_bookmarksnumbered true
+\pdf_bookmarksopen true
+\pdf_bookmarksopenlevel 1
+\pdf_breaklinks false
+\pdf_pdfborder false
+\pdf_colorlinks true
+\pdf_backref false
+\pdf_pdfusetitle false
+\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false"
+\papersize a4
+\use_geometry false
+\use_package amsmath 1
+\use_package amssymb 1
+\use_package cancel 1
+\use_package esint 1
+\use_package mathdots 1
+\use_package mathtools 1
+\use_package mhchem 1
+\use_package stackrel 1
+\use_package stmaryrd 1
+\use_package undertilde 1
+\cite_engine basic
+\cite_engine_type default
+\biblio_style plain
+\use_bibtopic false
+\use_indices false
+\paperorientation portrait
+\suppress_date false
+\justification true
+\use_refstyle 0
+\use_minted 0
+\use_lineno 0
+\notefontcolor #0000ff
+\index Index
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 4
+\tocdepth 4
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style english
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 2
+\paperpagestyle headings
+\tablestyle default
+\tracking_changes false
+\output_changes false
+\change_bars false
+\postpone_fragile_content false
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict true
+\docbook_table_output 0
+\end_header
+
+\begin_body
+
+\begin_layout Title
+Developing \SpecialChar LyX
+
+\end_layout
+
+\begin_layout Description
+New
+\begin_inset space ~
+\end_inset
+
+valid
+\begin_inset space ~
+\end_inset
+
+value
+\begin_inset space ~
+\end_inset
+
+for
+\begin_inset space ~
+\end_inset
+
+an
+\begin_inset space ~
+\end_inset
+
+existing
+\begin_inset space ~
+\end_inset
+
+setting, e.
+\begin_inset space \thinspace{}
+\end_inset
+
+g.
+\end_layout
+
+\begin_deeper
+\begin_layout Description
+\paragraph_spacing single
+Automatically
+\begin_inset space ~
+\end_inset
+
+loaded
+\begin_inset space ~
+\end_inset
+
+math
+\begin_inset space ~
+\end_inset
+
+package The reason 
+\end_layout
+
+\begin_layout Description
+New
+\begin_inset space ~
+\end_inset
+
+language that is stored
+\end_layout
+
+\end_deeper
+\begin_layout Description
+New
+\begin_inset space ~
+\end_inset
+
+inset Of course a new inset requires a file format update.
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/docbook/description_list_nested.xml b/autotests/export/docbook/description_list_nested.xml
new file mode 100644
index 0000000..c08bec4
--- /dev/null
+++ b/autotests/export/docbook/description_list_nested.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- This DocBook file was created by LyX 2.4.0dev
+  See http://www.lyx.org/ for more information -->
+<article xml:lang="en_US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2">
+<title>Developing LyX</title>
+<variablelist>
+<varlistentry>
+<term>New&#xA0;valid&#xA0;value&#xA0;for&#xA0;an&#xA0;existing&#xA0;setting,</term>
+
+<listitem>
+<para> e.&#x2009;g.</para>
+<variablelist>
+<varlistentry>
+<term>Automatically&#xA0;loaded&#xA0;math&#xA0;package</term>
+
+<listitem>
+<para> The reason </para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>New&#xA0;language</term>
+
+<listitem>
+<para> that is stored</para>
+</listitem>
+</varlistentry>
+</variablelist>
+<!-- lastlay != nullptr; item tag: listitem; item wrapper tag: varlistentry --></listitem>
+<!-- has docbookwrappertag --></varlistentry>
+<varlistentry>
+<term>New&#xA0;inset</term>
+
+<listitem>
+<para> Of course a new inset requires a file format update.</para>
+</listitem>
+</varlistentry>
+</variablelist>
+
+</article>
\ No newline at end of file
diff --git a/autotests/export/docbook/lists.xml b/autotests/export/docbook/lists.xml
index 0468223..ae956c5 100644
--- a/autotests/export/docbook/lists.xml
+++ b/autotests/export/docbook/lists.xml
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This DocBook file was created by LyX 2.4.0dev
   See http://www.lyx.org/ for more information -->
-<article xml:lang="en_US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.1">
+<article xml:lang="en_US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2">
 <title>Test document</title>
-<para>A list: </para>
+<para>A list:</para>
 <itemizedlist>
 <listitem>
 <para>First item</para>
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 2224cd8..9c34115 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -257,7 +257,8 @@ void closeInnerItemTag(XMLStream &xs, Layout const &lay)
 
 inline void closeItemTag(XMLStream &xs, Layout const &lay)
 {
-	xs << xml::EndTag(lay.docbookitemtag()) << xml::CR();
+	xs << xml::EndTag(lay.docbookitemtag());
+	xs << xml::CR();
 }
 
 // end of convenience functions
@@ -507,11 +508,17 @@ ParagraphList::const_iterator makeEnvironment(
 			if (par->params().depth() == origdepth) {
 				LATTEST(bstyle == style);
 				if (lastlay != nullptr) {
+					xs << XMLStream::ESCAPE_NONE << ("<!-- lastlay != nullptr; item tag: " + from_utf8(lastlay->docbookitemtag()) + "; item wrapper tag: " + from_utf8(lastlay->docbookitemwrappertag()) + " -->");
 					closeItemTag(xs, *lastlay);
+					if (lastlay->docbookitemwrappertag() != "NONE") {
+						xs << XMLStream::ESCAPE_NONE << "<!-- has docbookwrappertag -->";
+						xs << xml::EndTag(lastlay->docbookitemwrappertag());
+						xs << xml::CR();
+					}
 					lastlay = nullptr;
 				}
 
-				// this will be positive, if we want to skip the
+				// this will be positive if we want to skip the
 				// initial word (if it's been taken for the label).
 				pos_type sep = 0;
 
@@ -585,8 +592,7 @@ ParagraphList::const_iterator makeEnvironment(
 					}
 				}
 			}
-			// The other possibility is that the depth has increased, in which
-			// case we need to recurse.
+			// The other possibility is that the depth has increased.
 			else {
 				send = findEndOfEnvironment(par, pend);
 				par = makeEnvironment(buf, xs, runparams, text, par, send);


More information about the lyx-cvs mailing list