[LyX features/feature/docbook] fix

Thibaut Cuvelier tcuvelier at lyx.org
Fri Sep 11 22:39:31 UTC 2020


The branch, feature/docbook, has been updated.
  discards  e63b8982896acd1c8932c7083925aa2cf3226ac9 (commit)
  discards  c29e0479053acd842ea7b1d3c93d090a05431ef5 (commit)
  discards  f71c76fa27117ffc1ea72d78efc496448d9d7e9f (commit)
  discards  4b4189205da17608e4d3b00feca97347a3e05f51 (commit)
  discards  e1c3fabd64309470b6c362bc0f1e3c043865ed83 (commit)
  discards  59574d9f4179d01b259b900b7e15df4c479b58da (commit)
  discards  b1ff6ed3c2dfc6fe191b7f77277109cde9c10889 (commit)
  discards  7e5fb04c8bd029ed53db804947563ce647d12b62 (commit)
  discards  509072e7ff34c4955d278c7b64c8471ce9d7d69c (commit)
  discards  ebc63715e0ad623591a2a81ee9509a079ecf3ce0 (commit)
  discards  530a4c4316cd8b344e6250895324b158aabee544 (commit)
  discards  11df82eec725ba970e4e4145f5efd0175fbe3314 (commit)
  discards  3dbf199f97c031122aad9f824c3a63ee745bb8ee (commit)
  discards  760ce75a0553f8b4da1f5792df75967817f73a00 (commit)
  discards  a91ad100a6dd09cd19a6feca7957acda45e5b7df (commit)
  discards  1c1cfd37282e081c1ec0bb1ad8e1d1dbe24f6d89 (commit)
  discards  450658410bbf5b31bdd23eb86f40784ac21f3f1c (commit)
  discards  307bed5b1c70b4491ea252d255acf79555b9f0a8 (commit)
  discards  654ae5dec24726f9074e54f57cdec141a8abb1bd (commit)
  discards  7ffbef57e92da17c96e6ed161a0e8784584b926d (commit)
  discards  42b172f8e66da257833239d22976831ab627402b (commit)
  discards  1366ab51493967b14e2c41e8ca85c0eaf6b7d024 (commit)
  discards  aa0841d2be92793e708f69f7d50ccd0414f5ef6b (commit)
  discards  4a8eca19eff02fb802a0e4b610e5ca9f0280b808 (commit)
  discards  412faa3a4d7996d8fa7555f64dafc3bb7f005c57 (commit)
  discards  4c44b2b0425b07e0b902d14da35c0269a2616143 (commit)
  discards  bc4dfdb52230f1c3d99a06174318f391626310a2 (commit)
  discards  9cc900369f814f74561ee028c555f60b71609e86 (commit)
  discards  d323147f4c8a2a780a609b95770c5d41decdbf7d (commit)
  discards  34d2645b3dbf8a6270609286785347b6b130ddbb (commit)
  discards  1e1455e32d277d30db272038dc0a095ae41af52d (commit)
  discards  5106d4d3371c109668853694c28c61494705018f (commit)
  discards  3ffea09bb8daba1a311ae73d9c85dcb6a7b5baff (commit)
  discards  16fefd0e40ff739fc7f2922a8142404272c6bac4 (commit)
  discards  247306ee6a4a60f61e49510407b7e163a4b3e80b (commit)
  discards  ef811509faf52fba6a67362a863b1eea6f9adee1 (commit)
  discards  863f233e56b3f2b5fe3196aa942633a60081562d (commit)
  discards  f9a0499ebd6c40721db98525b44f0db7b63fd4f5 (commit)
  discards  edf02602486c5f4b00dec618ed7c88416b20ad5e (commit)
  discards  7d0fe3fb31a88ba30adf94f2429f4f19e04bc90e (commit)
  discards  8493af51f49e153070285536beff03a5453bd374 (commit)
  discards  044687b43057d981a8be4a0e9df532e82bab1700 (commit)
  discards  d75cb05b9a6c0984655f1ca9d9d1e69d74def2c6 (commit)
  discards  e913048d41286087b64f4821de0fc2e4111a673d (commit)
  discards  333b7bf3aef80f29a194cbc72bc5b2fdeb972bf3 (commit)
  discards  012a1699dd4d0371d8526da718a20c73e53ab5e7 (commit)
  discards  4ff938c58a9a544864d6d6ecc329e77548ddf2ac (commit)
  discards  74e53c50f263ac1e6d2c180361e98ede1072cde1 (commit)
  discards  8e4f2b23f59b721ab292aabbfac965eb979b7476 (commit)
  discards  68f231169d9a1a9a0c003f9aff19f7148f10212c (commit)
  discards  52454337e77589f074ca4ccb8670eb5bf591cdba (commit)
  discards  ce4371188ad5bf52d24c4a8f60a42a25b6e53fa6 (commit)
  discards  81c122929caa7c9f65deacf604ce26bc67b3b124 (commit)
  discards  13914aca758a36b8a21e96341ac5d1a9a5eb8ce7 (commit)
  discards  1d5ce3bdbb5b695605f75a6e7661a018524ea5ee (commit)
  discards  86594ff5db0e259b9d33c577cedd3b3b8665771d (commit)
  discards  20f0f4c56e3e878c194fa5c646d4ee8c7154a60c (commit)
  discards  d8469039a58f30a52cc6014d620b23a02921213e (commit)
  discards  be19d32ade570acf767138f7a22a1343bbb7c568 (commit)
  discards  1d7860558d20ecf21cb2896b8049bfe0e0cd7138 (commit)
  discards  5debf3b056a65948477450fa74a7c543b695befa (commit)
  discards  a42baa2fb9134cd9beb912d012e9248d852d1414 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (e63b8982896acd1c8932c7083925aa2cf3226ac9)
            \
             N -- N -- N (3246af469b309bb1dacd278f3064b438329c96dd)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

- Log -----------------------------------------------------------------

commit 3246af469b309bb1dacd278f3064b438329c96dd
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Sep 12 01:04:43 2020 +0200

    fix

diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 7cf2332..74119bb 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -271,7 +271,7 @@ currentFormat = 84
 # Incremented to format 81, 12 August 2019 by rikiheck
 # New tag GuiName for counters
 
-# Incremented to format 82, 4 June 2017 by dourouc05
+# Incremented to format 82, 4 June 2017 by tcuvelier
 # - Add new tags for Layout:
 #   DocBookTag, DocBookAttr, DocBookInInfo,
 #   DocBookWrapperTag, DocBookWrapperAttr,
@@ -281,7 +281,7 @@ currentFormat = 84
 # - Removed tag Header from ClassOptionsClassOptions
 # - Removed tag Element for flex insets
 
-# Incremented to format 83, 2 August 2020 by dourouc05
+# Incremented to format 83, 2 August 2020 by tcuvelier
 # New tags DocBookWrapperMergeWithPrevious and DocBookAbstract
 
 # Incremented to format 84, 17 August 2020 by tcuvelier

commit 71f8d419e4ca3114e6e527725b673e580e713040
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Sep 12 00:39:23 2020 +0200

    DocBook: work for more subfigure cases.
    
    EmbeddedObjects hid quite a few gems :).

diff --git a/autotests/export/docbook/subfigures_EmbeddedObjects.lyx b/autotests/export/docbook/subfigures_EmbeddedObjects.lyx
new file mode 100644
index 0000000..0154d21
--- /dev/null
+++ b/autotests/export/docbook/subfigures_EmbeddedObjects.lyx
@@ -0,0 +1,444 @@
+#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 scrbook
+\begin_preamble
+% that links to image floats jumps
+% to the beginning of the float and 
+% not to its caption
+\usepackage[figure]{hypcap}
+
+% the pages of the TOC are numbered roman
+% and a PDF-bookmark for the TOC is added
+\let\myTOC\tableofcontents
+\renewcommand\tableofcontents{%
+  \frontmatter
+  \pdfbookmark[1]{\contentsname}{}
+  \myTOC
+  \mainmatter }
+
+% provides caption formatting
+\usepackage[labelfont={bf,sf}]{caption}[2004/07/16]
+
+% provides commands to set caption
+% beside tables/images
+\newcommand{\TabBesBeg}[1][1.0]{%
+ \let\MyTable\table
+ \let\MyEndtable\endtable
+ \renewenvironment{table}[1]{\begin{SCtable}[#1]##1}{\end{SCtable}}}
+
+\newcommand{\TabBesEnd}{%
+ \let\table\MyTable
+ \let\endtable\MyEndtable}
+
+\newcommand{\FigBesBeg}[1][1.0]{%
+ \let\MyFigure\figure
+ \let\MyEndfigure\endfigure
+ \renewenvironment{figure}[1]{\begin{SCfigure}[#1]##1}{\end{SCfigure}}}
+
+\newcommand{\FigBesEnd}{%
+ \let\figure\MyFigure
+ \let\endfigure\MyEndfigure}
+
+% enables calculation of values,
+\usepackage{calc}
+
+% increase the bottom float placement fraction
+\renewcommand{\bottomfraction}{0.5}
+
+% avoids that floats are placed before their
+% corresponding section starts
+\let\mySection\section\renewcommand{\section}{\suppressfloats[t]\mySection}
+
+% speed up the longtable calculation
+\setcounter{LTchunksize}{100}
+
+% used for colored tables
+\@ifundefined{textcolor}
+ {\usepackage{color}}{}
+\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}
+\definecolor{lightgrey}{gray}{0.8}
+
+% check for package colortbl
+% used for colored table cells
+\newboolean{colortbl}
+\IfFileExists{colortbl.sty}
+ {\usepackage{colortbl}
+  \setboolean{colortbl}{true}}
+ {\setboolean{colortbl}{false}}
+
+% used to have extra space in table cells
+\@ifundefined{extrarowheight}
+ {\usepackage{array}}{}
+\setlength{\extrarowheight}{2pt}
+
+% used for customized tables
+% ---
+\newcolumntype{M}[1]
+ {>{\centering\hspace{0pt}}m{#1}}
+
+\newcolumntype{S}[2]
+ {>{\centering\hspace{0pt}}m{(#1+(2\tabcolsep+\arrayrulewidth)*(1-#2))/#2}}
+
+\newcolumntype{K}[1]
+ {>{\columncolor{#1}\hspace{0pt}}c}
+
+\newcolumntype{V}{!{\vrule width 1.5pt}}
+
+\newcolumntype{W}{!{\color{green}\vline}}
+% ---
+
+% insert additional vertical space of
+% 1.5 mm between footnotes
+\let\myFoot\footnote
+\renewcommand{\footnote}[1]{\myFoot{#1\vspace{1.5mm}}}
+
+% number algorithm floats within chapters
+\numberwithin{algorithm}{chapter}
+
+% ------------------------------------
+% used to check for needed LaTeX packages
+\usepackage{ifthen}
+
+% check for package arydshln
+% used for tables with dashed lines
+\newboolean{arydshln}
+\IfFileExists{arydshln.sty}
+ {\usepackage{arydshln}
+  \setboolean{arydshln}{true}}
+ {\setboolean{arydshln}{false}}
+
+% check for package marginnote
+% used for margin notes
+\newboolean{marginnote}
+\IfFileExists{marginnote.sty}
+ {\usepackage{marginnote}
+  \let\marginpar\marginnote
+  \setboolean{marginnote}{true}}
+ {\setboolean{marginnote}{false}}
+
+% check for package sidecap
+% used for captions on the side
+\newboolean{sidecap}
+\IfFileExists{sidecap.sty}
+ {\usepackage{sidecap}
+  \setboolean{sidecap}{true}}
+ {\setboolean{sidecap}{false}}
+
+% check for picinpar
+% used for surrounded fixed objects
+\newboolean{picinpar}
+\IfFileExists{picinpar.sty}
+ {\usepackage{picinpar}
+  \setboolean{picinpar}{true}}
+ {\setboolean{picinpar}{false}}
+
+% check for lettrine
+\newboolean{lettrine}
+\IfFileExists{lettrine.sty}
+ {\usepackage{lettrine}
+  \setboolean{lettrine}{true}}
+ {\setboolean{lettrine}{false}}
+
+% check for diagbox
+\newboolean{diagbox}
+\IfFileExists{diagbox.sty}
+ {\usepackage{diagbox}
+  \setboolean{diagbox}{true}}
+ {\setboolean{diagbox}{false}}
+% Added by lyx2lyx
+\setlength{\parskip}{\medskipamount}
+\setlength{\parindent}{0pt}
+\end_preamble
+\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table
+\use_default_options false
+\begin_modules
+initials
+graphicboxes
+varwidth
+\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 0
+\bibtex_command default
+\index_command makeindex
+\paperfontsize 12
+\spacing single
+\use_hyperref true
+\pdf_title "LyX's Figure, Table, Floats, Notes, and Boxes manual"
+\pdf_author "LyX Team, Uwe Stöhr"
+\pdf_subject "LyX-documentation about figures, tables, floats, notes, and boxes"
+\pdf_keywords "LyX, Tables, Figures, Floats, Boxes, Notes"
+\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 default
+\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 3
+\tocdepth 3
+\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 default
+\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 false
+\docbook_table_output 0
+\end_header
+
+\begin_body
+
+\begin_layout Title
+\SpecialChar LyX
+'s detailed Figure, Table, Floats, Notes, Boxes and External Material manual
+\end_layout
+
+\begin_layout Chapter
+Figures
+\end_layout
+
+\begin_layout Section
+Figure Floats
+\end_layout
+
+\begin_layout Standard
+Normally only one image is inserted to a figure float, but sometimes you
+ might want to use two images with separate subcaptions.
+ This can be done by inserting image floats into existing image floats.
+ Note that only the main caption of the float is added to the List of Figures.
+ Figure
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "fig:Two-distorted-images"
+
+\end_inset
+
+ is an example of a figure float with two images set side by side.
+ You can also set the images one below the other.
+ Figure
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "fig:Pink-object"
+
+\end_inset
+
+ and 
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "fig:A-star"
+
+\end_inset
+
+ are the subfigures.
+\end_layout
+
+\begin_layout Standard
+\begin_inset Float figure
+placement document
+alignment document
+wide false
+sideways false
+status open
+
+\begin_layout Plain Layout
+\begin_inset space \hfill{}
+\end_inset
+
+
+\begin_inset Float figure
+placement document
+alignment document
+wide false
+sideways false
+status open
+
+\begin_layout Plain Layout
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+\begin_inset CommandInset label
+LatexCommand label
+name "fig:Pink-object"
+
+\end_inset
+
+Pink object.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Graphics
+	filename ../../../lib/doc/clipart/3D-structure-distort.pdf
+	width 45col%
+	scaleBeforeRotation
+	groupId distorted
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\begin_inset space \hfill{}
+\end_inset
+
+
+\begin_inset Float figure
+placement document
+alignment document
+wide false
+sideways false
+status open
+
+\begin_layout Plain Layout
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+\begin_inset CommandInset label
+LatexCommand label
+name "fig:A-star"
+
+\end_inset
+
+A star.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Graphics
+	filename ../../../lib/doc/clipart/Star-structure.pdf
+	width 45col%
+	scaleBeforeRotation
+	groupId distorted
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\begin_inset space \hfill{}
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+\begin_inset CommandInset label
+LatexCommand label
+name "fig:Two-distorted-images"
+
+\end_inset
+
+Two distorted images.
+ Both images are in the image settings group named 
+\begin_inset Quotes eld
+\end_inset
+
+distorted
+\begin_inset Quotes erd
+\end_inset
+
+.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/docbook/subfigures_EmbeddedObjects.xml b/autotests/export/docbook/subfigures_EmbeddedObjects.xml
new file mode 100644
index 0000000..08fda04
--- /dev/null
+++ b/autotests/export/docbook/subfigures_EmbeddedObjects.xml
@@ -0,0 +1,32 @@
+<?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 -->
+<book 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>LyX's detailed Figure, Table, Floats, Notes, Boxes and External Material manual</title>
+<chapter>
+<title>Figures</title>
+<section>
+<title>Figure Floats</title>
+<para>Normally only one image is inserted to a figure float, but sometimes you might want to use two images with separate subcaptions. This can be done by inserting image floats into existing image floats. Note that only the main caption of the float is added to the List of Figures. Figure&#xA0;<xref linkend="fig.Two-distorted-images" /> is an example of a figure float with two images set side by side. You can also set the images one below the other. Figure&#xA0;<xref linkend="fig.Pink-object" /> and <xref linkend="fig.A-star" /> are the subfigures.</para>
+<formalgroup xml:id="fig.Two-distorted-images">
+<title>Two distorted images. Both images are in the image settings group named “distorted”.</title>
+<figure xml:id="fig.Pink-object">
+<title>Pink object.</title>
+<mediaobject>
+<imageobject>
+<imagedata fileref="D:/LyX/lyx-unstable/lib/doc/clipart/3D-structure-distort.pdf"  width="45%"  />
+</imageobject>
+</mediaobject>
+</figure>
+<figure xml:id="fig.A-star">
+<title>A star.</title>
+<mediaobject>
+<imageobject>
+<imagedata fileref="D:/LyX/lyx-unstable/lib/doc/clipart/Star-structure.pdf"  width="45%"  />
+</imageobject>
+</mediaobject>
+</figure>
+</formalgroup>
+</section>
+</chapter>
+</book>
\ No newline at end of file
diff --git a/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.lyx b/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.lyx
new file mode 100644
index 0000000..da41aa3
--- /dev/null
+++ b/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.lyx
@@ -0,0 +1,420 @@
+#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 scrbook
+\begin_preamble
+% that links to image floats jumps
+% to the beginning of the float and 
+% not to its caption
+\usepackage[figure]{hypcap}
+
+% the pages of the TOC are numbered roman
+% and a PDF-bookmark for the TOC is added
+\let\myTOC\tableofcontents
+\renewcommand\tableofcontents{%
+  \frontmatter
+  \pdfbookmark[1]{\contentsname}{}
+  \myTOC
+  \mainmatter }
+
+% provides caption formatting
+\usepackage[labelfont={bf,sf}]{caption}[2004/07/16]
+
+% provides commands to set caption
+% beside tables/images
+\newcommand{\TabBesBeg}[1][1.0]{%
+ \let\MyTable\table
+ \let\MyEndtable\endtable
+ \renewenvironment{table}[1]{\begin{SCtable}[#1]##1}{\end{SCtable}}}
+
+\newcommand{\TabBesEnd}{%
+ \let\table\MyTable
+ \let\endtable\MyEndtable}
+
+\newcommand{\FigBesBeg}[1][1.0]{%
+ \let\MyFigure\figure
+ \let\MyEndfigure\endfigure
+ \renewenvironment{figure}[1]{\begin{SCfigure}[#1]##1}{\end{SCfigure}}}
+
+\newcommand{\FigBesEnd}{%
+ \let\figure\MyFigure
+ \let\endfigure\MyEndfigure}
+
+% enables calculation of values,
+\usepackage{calc}
+
+% increase the bottom float placement fraction
+\renewcommand{\bottomfraction}{0.5}
+
+% avoids that floats are placed before their
+% corresponding section starts
+\let\mySection\section\renewcommand{\section}{\suppressfloats[t]\mySection}
+
+% speed up the longtable calculation
+\setcounter{LTchunksize}{100}
+
+% used for colored tables
+\@ifundefined{textcolor}
+ {\usepackage{color}}{}
+\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}
+\definecolor{lightgrey}{gray}{0.8}
+
+% check for package colortbl
+% used for colored table cells
+\newboolean{colortbl}
+\IfFileExists{colortbl.sty}
+ {\usepackage{colortbl}
+  \setboolean{colortbl}{true}}
+ {\setboolean{colortbl}{false}}
+
+% used to have extra space in table cells
+\@ifundefined{extrarowheight}
+ {\usepackage{array}}{}
+\setlength{\extrarowheight}{2pt}
+
+% used for customized tables
+% ---
+\newcolumntype{M}[1]
+ {>{\centering\hspace{0pt}}m{#1}}
+
+\newcolumntype{S}[2]
+ {>{\centering\hspace{0pt}}m{(#1+(2\tabcolsep+\arrayrulewidth)*(1-#2))/#2}}
+
+\newcolumntype{K}[1]
+ {>{\columncolor{#1}\hspace{0pt}}c}
+
+\newcolumntype{V}{!{\vrule width 1.5pt}}
+
+\newcolumntype{W}{!{\color{green}\vline}}
+% ---
+
+% insert additional vertical space of
+% 1.5 mm between footnotes
+\let\myFoot\footnote
+\renewcommand{\footnote}[1]{\myFoot{#1\vspace{1.5mm}}}
+
+% number algorithm floats within chapters
+\numberwithin{algorithm}{chapter}
+
+% ------------------------------------
+% used to check for needed LaTeX packages
+\usepackage{ifthen}
+
+% check for package arydshln
+% used for tables with dashed lines
+\newboolean{arydshln}
+\IfFileExists{arydshln.sty}
+ {\usepackage{arydshln}
+  \setboolean{arydshln}{true}}
+ {\setboolean{arydshln}{false}}
+
+% check for package marginnote
+% used for margin notes
+\newboolean{marginnote}
+\IfFileExists{marginnote.sty}
+ {\usepackage{marginnote}
+  \let\marginpar\marginnote
+  \setboolean{marginnote}{true}}
+ {\setboolean{marginnote}{false}}
+
+% check for package sidecap
+% used for captions on the side
+\newboolean{sidecap}
+\IfFileExists{sidecap.sty}
+ {\usepackage{sidecap}
+  \setboolean{sidecap}{true}}
+ {\setboolean{sidecap}{false}}
+
+% check for picinpar
+% used for surrounded fixed objects
+\newboolean{picinpar}
+\IfFileExists{picinpar.sty}
+ {\usepackage{picinpar}
+  \setboolean{picinpar}{true}}
+ {\setboolean{picinpar}{false}}
+
+% check for lettrine
+\newboolean{lettrine}
+\IfFileExists{lettrine.sty}
+ {\usepackage{lettrine}
+  \setboolean{lettrine}{true}}
+ {\setboolean{lettrine}{false}}
+
+% check for diagbox
+\newboolean{diagbox}
+\IfFileExists{diagbox.sty}
+ {\usepackage{diagbox}
+  \setboolean{diagbox}{true}}
+ {\setboolean{diagbox}{false}}
+% Added by lyx2lyx
+\setlength{\parskip}{\medskipamount}
+\setlength{\parindent}{0pt}
+\end_preamble
+\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table
+\use_default_options false
+\begin_modules
+initials
+graphicboxes
+varwidth
+\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 0
+\bibtex_command default
+\index_command makeindex
+\paperfontsize 12
+\spacing single
+\use_hyperref true
+\pdf_title "LyX's Figure, Table, Floats, Notes, and Boxes manual"
+\pdf_author "LyX Team, Uwe Stöhr"
+\pdf_subject "LyX-documentation about figures, tables, floats, notes, and boxes"
+\pdf_keywords "LyX, Tables, Figures, Floats, Boxes, Notes"
+\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 default
+\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 3
+\tocdepth 3
+\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 default
+\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 false
+\docbook_table_output 0
+\end_header
+
+\begin_body
+
+\begin_layout Title
+\SpecialChar LyX
+'s detailed Figure, Table, Floats, Notes, Boxes and External Material manual
+\end_layout
+
+\begin_layout Chapter
+Floats
+\end_layout
+
+\begin_layout Section
+Floats Side by Side
+\end_layout
+
+\begin_layout Standard
+To place floats side by side, as in Figures
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "fig:Float-left"
+
+\end_inset
+
+ and 
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "fig:Float-right"
+
+\end_inset
+
+, only 
+\emph on
+one
+\emph default
+ float is used.
+ In it two minipage boxes are inserted.
+ 
+\end_layout
+
+\begin_layout Standard
+\begin_inset Float figure
+placement document
+alignment document
+wide false
+sideways false
+status open
+
+\begin_layout Plain Layout
+\begin_inset Box Frameless
+position "b"
+hor_pos "c"
+has_inner_box 1
+inner_pos "t"
+use_parbox 0
+use_makebox 0
+width "45col%"
+special "none"
+height "1in"
+height_special "totalheight"
+thickness "0.4pt"
+separation "3pt"
+shadowsize "4pt"
+framecolor "black"
+backgroundcolor "none"
+status open
+
+\begin_layout Plain Layout
+\align center
+\begin_inset Graphics
+	filename ../../../lib/doc/clipart/2D-intensity-plot.pdf
+	width 100col%
+	scaleBeforeRotation
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+\begin_inset CommandInset label
+LatexCommand label
+name "fig:Float-left"
+
+\end_inset
+
+Float on the left side.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\begin_inset space \hfill{}
+\end_inset
+
+
+\begin_inset Box Frameless
+position "b"
+hor_pos "c"
+has_inner_box 1
+inner_pos "t"
+use_parbox 0
+use_makebox 0
+width "45col%"
+special "none"
+height "1in"
+height_special "totalheight"
+thickness "0.4pt"
+separation "3pt"
+shadowsize "4pt"
+framecolor "black"
+backgroundcolor "none"
+status open
+
+\begin_layout Plain Layout
+\align center
+\begin_inset Graphics
+	filename ../../../lib/doc/clipart/Star-structure.pdf
+	width 100col%
+	scaleBeforeRotation
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+\begin_inset CommandInset label
+LatexCommand label
+name "fig:Float-right"
+
+\end_inset
+
+Float on the right side.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.xml b/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.xml
new file mode 100644
index 0000000..7f010cf
--- /dev/null
+++ b/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.xml
@@ -0,0 +1,32 @@
+<?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 -->
+<book 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>LyX's detailed Figure, Table, Floats, Notes, Boxes and External Material manual</title>
+<chapter>
+<title>Floats</title>
+<section>
+<title>Floats Side by Side</title>
+<para>To place floats side by side, as in Figures&#xA0;<xref linkend="fig.Float-left" /> and <xref linkend="fig.Float-right" />, only <emphasis>one</emphasis> float is used. In it two minipage boxes are inserted. </para>
+<formalgroup>
+<title>No caption</title>
+<figure xml:id="fig.Float-left">
+<title>Float on the left side.</title>
+<mediaobject>
+<imageobject>
+<imagedata fileref="D:/LyX/lyx-unstable/lib/doc/clipart/2D-intensity-plot.pdf"  width="100%"  />
+</imageobject>
+</mediaobject>
+</figure>
+<figure xml:id="fig.Float-right">
+<title>Float on the right side.</title>
+<mediaobject>
+<imageobject>
+<imagedata fileref="D:/LyX/lyx-unstable/lib/doc/clipart/Star-structure.pdf"  width="100%"  />
+</imageobject>
+</mediaobject>
+</figure>
+</formalgroup>
+</section>
+</chapter>
+</book>
\ No newline at end of file
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index eaa24cb..4e7db11 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -566,6 +566,66 @@ const InsetCaption* findCaptionInParagraph(const Paragraph &par)
 }
 
 
+/// Takes an unstructured subfigure container (typically, an InsetBox) and find the elements within:
+/// actual content (image or table), maybe a caption, maybe a label.
+std::tuple<InsetCode, const Inset *, const InsetCaption *, const InsetLabel *> docbookParseHopelessSubfigure(const InsetText * subfigure)
+{
+	InsetCode type = NO_CODE;
+	const Inset * content = nullptr;
+	const InsetCaption * caption = nullptr;
+	const InsetLabel * label = nullptr;
+
+	for (const auto & it : subfigure->paragraphs()) {
+		for (pos_type posIn = 0; posIn < it.size(); ++posIn) {
+			const Inset * inset = it.getInset(posIn);
+			if (inset) {
+				switch (inset->lyxCode()) {
+					case GRAPHICS_CODE:
+					case TABULAR_CODE:
+						if (!content) {
+							content = inset;
+							type = inset->lyxCode();
+						}
+						break;
+					case CAPTION_CODE:
+						if (!caption) {
+							caption = dynamic_cast<const InsetCaption *>(inset);
+
+							// A label often hides in a caption. Make a simplified version of the main loop.
+							if (!label) {
+								for (const auto &cit : caption->paragraphs()) {
+									for (pos_type cposIn = 0; cposIn < cit.size(); ++cposIn) {
+										const Inset *cinset = cit.getInset(posIn);
+										if (cinset && cinset->lyxCode() == LABEL_CODE) {
+											label = dynamic_cast<const InsetLabel *>(cinset);
+											break;
+										}
+									}
+
+									if (label)
+										break;
+								}
+							}
+						}
+						break;
+					case LABEL_CODE:
+						if (!label)
+							label = dynamic_cast<const InsetLabel *>(inset);
+						break;
+					default:
+						break;
+				}
+			}
+		}
+
+		if (content && caption && label)
+			break;
+	}
+
+	return std::make_tuple(type, content, caption, label);
+}
+
+
 void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const InsetCaption * caption,
 					   const InsetLabel * label, std::vector<const InsetCollapsible *> & subfigures)
 {
@@ -595,22 +655,27 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins
 
 	// Deal with each subfigure individually. This should also deal with their caption and their label.
 	// This should be a recursive call to InsetFloat.
-	// An item in subfigure should either be an InsetBox containing an InsetFloat or directly an InsetFloat.
-	for (const InsetCollapsible *subfigure: subfigures) {
-		// If there is no InsetFloat in the paragraphs, output a warning.
-		bool foundInsetFloat = false;
+	// An item in subfigure should either be an InsetBox containing an InsetFloat, or an InsetBox directly containing
+	// an image or a table, or directly an InsetFloat.
+	for (const InsetCollapsible * subfigure: subfigures) {
+		if (subfigure == nullptr)
+			continue;
 
 		// The collapsible may already be a float (InsetFloat).
-		if (subfigure && dynamic_cast<const InsetFloat *>(subfigure))
-			foundInsetFloat = true;
+		if (dynamic_cast<const InsetFloat *>(subfigure)) {
+			subfigure->docbook(xs, runparams);
+			continue;
+		}
 
-		// Subfigures are in boxes.
-		if (!foundInsetFloat) {
+		// Subfigures are in boxes, then in InsetFloat.
+		{
+			bool foundInsetFloat = false;
 			for (const auto &it : subfigure->paragraphs()) {
 				for (pos_type posIn = 0; posIn < it.size(); ++posIn) {
 					const Inset *inset = it.getInset(posIn);
-					if (inset && dynamic_cast<const InsetFloat *>(inset)) {
+					if (inset && inset->lyxCode() == FLOAT_CODE) {
 						foundInsetFloat = true;
+						inset->docbook(xs, runparams);
 						break;
 					}
 				}
@@ -618,15 +683,79 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins
 				if (foundInsetFloat)
 					break;
 			}
+			if (foundInsetFloat)
+				continue;
+		}
+
+		// Subfigures are in boxes, then directly an image or a table. In that case, generate the whole content of the
+		// InsetBox, but not the box container.
+		// Impose some model on the subfigure: at most a caption, at most a label, exactly one figure or one table.
+		{
+			InsetCode stype = NO_CODE;
+			const Inset * scontent = nullptr;
+			const InsetCaption * scaption = nullptr;
+			const InsetLabel * slabel = nullptr;
+
+			std::tie(stype, scontent, scaption, slabel) = docbookParseHopelessSubfigure(subfigure);
+
+			// If there is something, generate it. This is very much like docbookNoSubfigures, but many things
+			// must be coded differently because there is no float.
+			// TODO: some code is identical to Floating, like Floating::docbookTag or Floating::docbookCaption. How to reuse that code?
+			if (scontent) {
+				// Floating::docbookCaption()
+				string docbook_caption = "caption"; // This is already correct for tables.
+				if (stype == GRAPHICS_CODE)
+					docbook_caption = "title";
+
+				// Floating::docbookTag() with hasTitle = true, as we are in formalgroup.
+				string stag = "float";
+				if (stype == GRAPHICS_CODE)
+					stag = "figure";
+				else if (stype == TABULAR_CODE)
+					stag = "table";
+
+				// Ensure there is no label output, it is supposed to be handled as xml:id.
+				if (slabel)
+					rpNoLabel.docbook_anchors_to_ignore.emplace(slabel->screenLabel());
+
+				// Ensure the float does not output its caption, as it is handled here (DocBook mandates a specific place for
+				// captions, they cannot appear at the end of the float, albeit LyX is happy with that).
+				OutputParams rpNoTitle = runparams;
+				rpNoTitle.docbook_in_float = true;
+				if (stype == TABULAR_CODE)
+					rpNoTitle.docbook_in_table = true;
+
+				// Organisation: <float> <title if any/> <contents without title/> </float>.
+				docstring sattr = docstring();
+				if (slabel)
+					sattr += "xml:id=\"" + xml::cleanID(slabel->screenLabel()) + "\"";
+				// No layout way of adding attributes, unlike the normal code path.
+
+				xs << xml::StartTag(stag, sattr);
+				xs << xml::CR();
+				xs << xml::StartTag(docbook_caption);
+				if (scaption)
+					scaption->getCaptionAsDocBook(xs, rpNoLabel);
+				else // Mandatory in formalgroup.
+					xs << "No caption detected";
+				xs << xml::EndTag(docbook_caption);
+				xs << xml::CR();
+				scontent->docbook(xs, rpNoTitle);
+				xs << xml::EndTag(stag);
+				xs << xml::CR();
+
+				// This subfigure could be generated.
+				continue;
+			}
 		}
 
-		if (!foundInsetFloat)
-			xs << XMLStream::ESCAPE_NONE << "Error: no float found in the box. "
-								"To use subfigures in DocBook, elements must be wrapped in a float "
-			                    "inset and have a title/caption.";
+		// If there is no InsetFloat in the inset, output a warning.
+		xs << XMLStream::ESCAPE_NONE << "Error: no float found in the box. "
+							"To use subfigures in DocBook, elements must be wrapped in a float "
+		                    "inset and have a title/caption.";
 		// TODO: could also output a table, that would ensure that the document is correct and *displays* correctly (but without the right semantics), instead of just an error.
 
-		// Finally, recurse.
+		// Recurse to generate as much content as possible (avoid any loss).
 		subfigure->docbook(xs, runparams);
 	}
 

commit e00770d1e9f94a82b8c3719167480ab2b15ce049
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Fri Sep 11 23:38:11 2020 +0200

    DocBook: ensure xml:id is not output too many times.
    
    This is mostly important for subfigures, but debugging this issue showed that InsetCaption could be slightly simplified and InsetLabel should be made a tad more robust.

diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp
index 0291625..8297c6f 100644
--- a/src/insets/InsetCaption.cpp
+++ b/src/insets/InsetCaption.cpp
@@ -367,8 +367,7 @@ void InsetCaption::getCaptionAsDocBook(XMLStream & xs,
 		return;
 
 	// Ignore full_label_, as the DocBook processor will deal with the numbering.
-	InsetText::XHTMLOptions const opts =
-			InsetText::WriteLabel | InsetText::WriteInnerTag;
+	InsetText::XHTMLOptions opts = InsetText::WriteInnerTag;
 	InsetText::docbook(xs, runparams, opts);
 }
 
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index d680013..eaa24cb 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -583,7 +583,7 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins
 	xs << xml::StartTag("formalgroup", attr);
 	xs << xml::CR();
 
-	xs << xml::StartTag("title", attr);
+	xs << xml::StartTag("title"); // Don't take attr here, the ID should only go in one place, not two.
 	if (caption) {
 		caption->getCaptionAsDocBook(xs, rpNoLabel);
 	} else {
diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp
index 2e80e26..5ba0344 100644
--- a/src/insets/InsetLabel.cpp
+++ b/src/insets/InsetLabel.cpp
@@ -356,8 +356,11 @@ int InsetLabel::plaintext(odocstringstream & os,
 void InsetLabel::docbook(XMLStream & xs, OutputParams const & runparams) const
 {
 	// Output an anchor only if it has not been processed before.
-	if (runparams.docbook_anchors_to_ignore.find(getParam("name")) == runparams.docbook_anchors_to_ignore.end()) {
-		docstring attr = from_utf8("xml:id=\"") + xml::cleanID(getParam("name")) + from_utf8("\"");
+	docstring id = getParam("name");
+	docstring cleaned_id = xml::cleanID(id);
+	if (runparams.docbook_anchors_to_ignore.find(id) == runparams.docbook_anchors_to_ignore.end() &&
+	        runparams.docbook_anchors_to_ignore.find(cleaned_id) == runparams.docbook_anchors_to_ignore.end()) {
+		docstring attr = from_utf8("xml:id=\"") + cleaned_id + from_utf8("\"");
 		xs << xml::CompTag("anchor", to_utf8(attr));
 	}
 }

commit c15863a8a62d3bd167bb9213b34545e0a2742dad
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Fri Sep 11 03:14:41 2020 +0200

    DocBook: handle other cases of subfigures.

diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index 981ba40..d680013 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -492,19 +492,22 @@ int InsetFloat::plaintext(odocstringstream & os, OutputParams const & runparams,
 }
 
 
-std::vector<const InsetBox *> findSubfiguresInParagraph(const Paragraph &par)
+std::vector<const InsetCollapsible *> findSubfiguresInParagraph(const Paragraph &par)
 {
 
 	// Don't make the hypothesis that all subfigures are in the same paragraph.
 	// Similarly, there may be several subfigures in the same paragraph (most likely case, based on the documentation).
 	// Any box is considered as a subfigure, even though the most likely case is \minipage.
-	std::vector<const InsetBox *> subfigures;
+	// Boxes are not required to make subfigures. The common root between InsetBox and InsetFLoat is InsetCollapsible.
+	std::vector<const InsetCollapsible *> subfigures;
 	for (pos_type pos = 0; pos < par.size(); ++pos) {
 		const Inset *inset = par.getInset(pos);
 		if (!inset)
 			continue;
 		if (const auto box = dynamic_cast<const InsetBox *>(inset))
 			subfigures.push_back(box);
+		else if (const auto fl = dynamic_cast<const InsetFloat *>(inset))
+			subfigures.push_back(fl);
 	}
 	return subfigures;
 }
@@ -564,7 +567,7 @@ const InsetCaption* findCaptionInParagraph(const Paragraph &par)
 
 
 void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const InsetCaption * caption,
-					   const InsetLabel * label, std::vector<const InsetBox *> & subfigures)
+					   const InsetLabel * label, std::vector<const InsetCollapsible *> & subfigures)
 {
 	// Ensure there is no label output, it is supposed to be handled as xml:id.
 	OutputParams rpNoLabel = runparams;
@@ -592,20 +595,29 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins
 
 	// Deal with each subfigure individually. This should also deal with their caption and their label.
 	// This should be a recursive call to InsetFloat.
-	for (const InsetBox *subfigure: subfigures) {
+	// An item in subfigure should either be an InsetBox containing an InsetFloat or directly an InsetFloat.
+	for (const InsetCollapsible *subfigure: subfigures) {
 		// If there is no InsetFloat in the paragraphs, output a warning.
 		bool foundInsetFloat = false;
-		for (const auto & it : subfigure->paragraphs()) {
-			for (pos_type posIn = 0; posIn < it.size(); ++posIn) {
-				const Inset *inset = it.getInset(posIn);
-				if (inset && dynamic_cast<const InsetFloat*>(inset)) {
-					foundInsetFloat = true;
-					break;
+
+		// The collapsible may already be a float (InsetFloat).
+		if (subfigure && dynamic_cast<const InsetFloat *>(subfigure))
+			foundInsetFloat = true;
+
+		// Subfigures are in boxes.
+		if (!foundInsetFloat) {
+			for (const auto &it : subfigure->paragraphs()) {
+				for (pos_type posIn = 0; posIn < it.size(); ++posIn) {
+					const Inset *inset = it.getInset(posIn);
+					if (inset && dynamic_cast<const InsetFloat *>(inset)) {
+						foundInsetFloat = true;
+						break;
+					}
 				}
-			}
 
-			if (foundInsetFloat)
-				break;
+				if (foundInsetFloat)
+					break;
+			}
 		}
 
 		if (!foundInsetFloat)
@@ -673,11 +685,11 @@ void InsetFloat::docbook(XMLStream & xs, OutputParams const & runparams) const
 	// The caption and the label for each subfigure is handled by recursive calls.
 	const InsetCaption* caption = nullptr;
 	const InsetLabel* label = nullptr;
-	std::vector<const InsetBox *> subfigures;
+	std::vector<const InsetCollapsible *> subfigures;
 
 	auto end = paragraphs().end();
 	for (auto it = paragraphs().begin(); it != end; ++it) {
-		std::vector<const InsetBox *> foundSubfigures = findSubfiguresInParagraph(*it);
+		std::vector<const InsetCollapsible *> foundSubfigures = findSubfiguresInParagraph(*it);
 		if (!foundSubfigures.empty()) {
 			subfigures.reserve(subfigures.size() + foundSubfigures.size());
 			subfigures.insert(subfigures.end(), foundSubfigures.begin(), foundSubfigures.end());

commit 6011a6eb0ef6eb393ea6e1c9e9fde4e2d696e93c
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Fri Sep 11 03:05:04 2020 +0200

    DocBook: in configure.py, DeclareDocBookClass doesn't need to be checked anymore.

diff --git a/lib/configure.py b/lib/configure.py
index 2247c78..6cb1c70 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1311,7 +1311,7 @@ def _checkForClassExtension(x):
         return x.strip()
 
 def processLayoutFile(file):
-    ''' process layout file and get a line of result
+    """ process layout file and get a line of result
 
         Declare lines look like this:
 
@@ -1336,38 +1336,36 @@ def processLayoutFile(file):
         "article" "article" "article" "false" "article.cls" "Articles"
         "scrbook" "scrbook" "book (koma-script)" "false" "scrbook.cls" "Books"
         "svjog" "svjour" "article (Springer - svjour/jog)" "false" "svjour.cls,svjog.clo" ""
-    '''
+    """
     classname = file.split(os.sep)[-1].split('.')[0]
-    # return ('LaTeX', '[a,b]', 'a', ',b,c', 'article') for \DeclareLaTeXClass[a,b,c]{article}
-    p = re.compile('\s*#\s*\\\\Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)}\s*$')
+    # return ('[a,b]', 'a', ',b,c', 'article') for \DeclareLaTeXClass[a,b,c]{article}
+    p = re.compile('\s*#\s*\\\\DeclareLaTeXClass\s*(\[([^,]*)(,.*)*])*\s*{(.*)}\s*$')
     q = re.compile('\s*#\s*\\\\DeclareCategory{(.*)}\s*$')
     classdeclaration = ""
     categorydeclaration = '""'
     for line in open(file, 'r', encoding='utf8').readlines():
         res = p.match(line)
         qres = q.match(line)
-        if res != None:
-            (classtype, optAll, opt, opt1, desc) = res.groups()
-            avai = {'LaTeX': 'false', 'DocBook': 'true'}[classtype]
-            if opt == None:
+        if res is not None:
+            (optAll, opt, opt1, desc) = res.groups()
+            if opt is None:
                 opt = classname
-                prereq_latex = _checkForClassExtension(classname)
+                prereq = _checkForClassExtension(classname)
             else:
                 prereq_list = optAll[1:-1].split(',')
                 prereq_list = list(map(_checkForClassExtension, prereq_list))
-                prereq_latex = ','.join(prereq_list)
-            prereq = {'LaTeX': prereq_latex, 'DocBook': ''}[classtype]
+                prereq = ','.join(prereq_list)
             classdeclaration = ('"%s" "%s" "%s" "%s" "%s"'
-                               % (classname, opt, desc, avai, prereq))
+                               % (classname, opt, desc, 'false', prereq))
             if categorydeclaration != '""':
                 return classdeclaration + " " + categorydeclaration
-        if qres != None:
-             categorydeclaration = '"%s"' % (qres.groups()[0])
-             if classdeclaration:
-                 return classdeclaration + " " + categorydeclaration
+        if qres is not None:
+            categorydeclaration = '"%s"' % (qres.groups()[0])
+            if classdeclaration:
+                return classdeclaration + " " + categorydeclaration
     if classdeclaration:
         return classdeclaration + " " + categorydeclaration
-    logger.warning("Layout file " + file + " has no \DeclareXXClass line. ")
+    logger.warning("Layout file " + file + " has no \\DeclareLaTeXClass line. ")
     return ""
 
 
@@ -1434,7 +1432,7 @@ def checkLatexConfig(check_config):
     # Construct the list of classes to test for.
     # build the list of available layout files and convert it to commands
     # for chkconfig.ltx
-    declare = re.compile('\\s*#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*(\[([^,]*)(,.*)*\])*\\s*{(.*)}\\s*$')
+    declare = re.compile('\\s*#\\s*\\\\DeclareLaTeXClass\\s*(\[([^,]*)(,.*)*\])*\\s*{(.*)}\\s*$')
     category = re.compile('\\s*#\\s*\\\\DeclareCategory{(.*)}\\s*$')
     empty = re.compile('\\s*$')
     testclasses = list()
@@ -1455,10 +1453,10 @@ def checkLatexConfig(check_config):
                         nodeclaration = True
                     # A class, but no category declaration. Just break.
                     break
-                if declare.match(line) != None:
+                if declare.match(line) is not None:
                     decline = "\\TestDocClass{%s}{%s}" % (classname, line[1:].strip())
                     testclasses.append(decline)
-                elif category.match(line) != None:
+                elif category.match(line) is not None:
                     catline = ("\\DeclareCategory{%s}{%s}"
                                % (classname, category.match(line).groups()[0]))
                     testclasses.append(catline)

commit a74c1963559feef65a5342714e248d4b4c65beb7
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Fri Sep 11 01:50:26 2020 +0200

    DocBook: remove now useless function in configure.py.

diff --git a/lib/configure.py b/lib/configure.py
index 1547000..2247c78 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1265,26 +1265,6 @@ def checkConverterEntries():
 ''')
 
 
-def checkDocBook():
-    ''' Check docbook '''
-    path, DOCBOOK = checkProg('SGML-tools 2.x (DocBook), db2x scripts or xsltproc', ['sgmltools', 'db2dvi', 'xsltproc'],
-        rc_entry = [
-            r'''\converter docbook    dvi        "sgmltools -b dvi $$i"	""
-\converter docbook    html       "sgmltools -b html $$i"	""
-\converter docbook    ps         "sgmltools -b ps $$i"	""''',
-            r'''\converter docbook    dvi        "db2dvi $$i"	""
-\converter docbook    html       "db2html $$i"	""''',
-            r'''\converter docbook    dvi        ""	""
-\converter docbook    html       "" ""''',
-            r'''\converter docbook    dvi        ""	""
-\converter docbook    html       ""	""'''])
-    #
-    if DOCBOOK:
-        return ('yes', 'true', '\\def\\hasdocbook{yes}')
-    else:
-        return ('no', 'false', '')
-
-
 def checkOtherEntries():
     ''' entries other than Format and Converter '''
     checkProg('ChkTeX', ['chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38'],

commit 604ba1b77e788d2c5c865cb59c81aaec36dcd43f
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Fri Sep 11 01:28:59 2020 +0200

    DocBook: fix handling of new lines and fonts.
    
    Only the font variable was restored to the right state, not fs.

diff --git a/autotests/export/docbook/fonts_EmbeddedObjects.lyx b/autotests/export/docbook/fonts_EmbeddedObjects.lyx
new file mode 100644
index 0000000..9ea1ff1
--- /dev/null
+++ b/autotests/export/docbook/fonts_EmbeddedObjects.lyx
@@ -0,0 +1,288 @@
+#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 scrbook
+\begin_preamble
+% that links to image floats jumps
+% to the beginning of the float and 
+% not to its caption
+\usepackage[figure]{hypcap}
+
+% the pages of the TOC are numbered roman
+% and a PDF-bookmark for the TOC is added
+\let\myTOC\tableofcontents
+\renewcommand\tableofcontents{%
+  \frontmatter
+  \pdfbookmark[1]{\contentsname}{}
+  \myTOC
+  \mainmatter }
+
+% provides caption formatting
+\usepackage[labelfont={bf,sf}]{caption}[2004/07/16]
+
+% provides commands to set caption
+% beside tables/images
+\newcommand{\TabBesBeg}[1][1.0]{%
+ \let\MyTable\table
+ \let\MyEndtable\endtable
+ \renewenvironment{table}[1]{\begin{SCtable}[#1]##1}{\end{SCtable}}}
+
+\newcommand{\TabBesEnd}{%
+ \let\table\MyTable
+ \let\endtable\MyEndtable}
+
+\newcommand{\FigBesBeg}[1][1.0]{%
+ \let\MyFigure\figure
+ \let\MyEndfigure\endfigure
+ \renewenvironment{figure}[1]{\begin{SCfigure}[#1]##1}{\end{SCfigure}}}
+
+\newcommand{\FigBesEnd}{%
+ \let\figure\MyFigure
+ \let\endfigure\MyEndfigure}
+
+% enables calculation of values,
+\usepackage{calc}
+
+% increase the bottom float placement fraction
+\renewcommand{\bottomfraction}{0.5}
+
+% avoids that floats are placed before their
+% corresponding section starts
+\let\mySection\section\renewcommand{\section}{\suppressfloats[t]\mySection}
+
+% speed up the longtable calculation
+\setcounter{LTchunksize}{100}
+
+% used for colored tables
+\@ifundefined{textcolor}
+ {\usepackage{color}}{}
+\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}
+\definecolor{lightgrey}{gray}{0.8}
+
+% check for package colortbl
+% used for colored table cells
+\newboolean{colortbl}
+\IfFileExists{colortbl.sty}
+ {\usepackage{colortbl}
+  \setboolean{colortbl}{true}}
+ {\setboolean{colortbl}{false}}
+
+% used to have extra space in table cells
+\@ifundefined{extrarowheight}
+ {\usepackage{array}}{}
+\setlength{\extrarowheight}{2pt}
+
+% used for customized tables
+% ---
+\newcolumntype{M}[1]
+ {>{\centering\hspace{0pt}}m{#1}}
+
+\newcolumntype{S}[2]
+ {>{\centering\hspace{0pt}}m{(#1+(2\tabcolsep+\arrayrulewidth)*(1-#2))/#2}}
+
+\newcolumntype{K}[1]
+ {>{\columncolor{#1}\hspace{0pt}}c}
+
+\newcolumntype{V}{!{\vrule width 1.5pt}}
+
+\newcolumntype{W}{!{\color{green}\vline}}
+% ---
+
+% insert additional vertical space of
+% 1.5 mm between footnotes
+\let\myFoot\footnote
+\renewcommand{\footnote}[1]{\myFoot{#1\vspace{1.5mm}}}
+
+% number algorithm floats within chapters
+\numberwithin{algorithm}{chapter}
+
+% ------------------------------------
+% used to check for needed LaTeX packages
+\usepackage{ifthen}
+
+% check for package arydshln
+% used for tables with dashed lines
+\newboolean{arydshln}
+\IfFileExists{arydshln.sty}
+ {\usepackage{arydshln}
+  \setboolean{arydshln}{true}}
+ {\setboolean{arydshln}{false}}
+
+% check for package marginnote
+% used for margin notes
+\newboolean{marginnote}
+\IfFileExists{marginnote.sty}
+ {\usepackage{marginnote}
+  \let\marginpar\marginnote
+  \setboolean{marginnote}{true}}
+ {\setboolean{marginnote}{false}}
+
+% check for package sidecap
+% used for captions on the side
+\newboolean{sidecap}
+\IfFileExists{sidecap.sty}
+ {\usepackage{sidecap}
+  \setboolean{sidecap}{true}}
+ {\setboolean{sidecap}{false}}
+
+% check for picinpar
+% used for surrounded fixed objects
+\newboolean{picinpar}
+\IfFileExists{picinpar.sty}
+ {\usepackage{picinpar}
+  \setboolean{picinpar}{true}}
+ {\setboolean{picinpar}{false}}
+
+% check for lettrine
+\newboolean{lettrine}
+\IfFileExists{lettrine.sty}
+ {\usepackage{lettrine}
+  \setboolean{lettrine}{true}}
+ {\setboolean{lettrine}{false}}
+
+% check for diagbox
+\newboolean{diagbox}
+\IfFileExists{diagbox.sty}
+ {\usepackage{diagbox}
+  \setboolean{diagbox}{true}}
+ {\setboolean{diagbox}{false}}
+% Added by lyx2lyx
+\setlength{\parskip}{\medskipamount}
+\setlength{\parindent}{0pt}
+\end_preamble
+\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table
+\use_default_options false
+\begin_modules
+initials
+graphicboxes
+varwidth
+\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 0
+\bibtex_command default
+\index_command makeindex
+\paperfontsize 12
+\spacing single
+\use_hyperref true
+\pdf_title "LyX's Figure, Table, Floats, Notes, and Boxes manual"
+\pdf_author "LyX Team, Uwe Stöhr"
+\pdf_subject "LyX-documentation about figures, tables, floats, notes, and boxes"
+\pdf_keywords "LyX, Tables, Figures, Floats, Boxes, Notes"
+\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 default
+\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 3
+\tocdepth 3
+\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 default
+\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 false
+\docbook_table_output 0
+\end_header
+
+\begin_body
+
+\begin_layout Title
+\SpecialChar LyX
+'s detailed Figure, Table, Floats, Notes, Boxes and External Material manual
+\end_layout
+
+\begin_layout Chapter
+Floats
+\end_layout
+
+\begin_layout Standard
+can be created using these commands in the document preamble:
+\end_layout
+
+\begin_layout Standard
+
+\series bold
+
+\backslash
+usepackage[tableposition=top]{caption}
+\series default
+
+\begin_inset Newline newline
+\end_inset
+
+
+\series bold
+
+\backslash
+captionsetup[figure]{labelfont={tt}, textfont=it, indention=1cm,%
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/docbook/fonts_EmbeddedObjects.xml b/autotests/export/docbook/fonts_EmbeddedObjects.xml
new file mode 100644
index 0000000..7ce65a1
--- /dev/null
+++ b/autotests/export/docbook/fonts_EmbeddedObjects.xml
@@ -0,0 +1,12 @@
+<?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 -->
+<book 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>LyX's detailed Figure, Table, Floats, Notes, Boxes and External Material manual</title>
+<chapter>
+<title>Floats</title>
+<para>can be created using these commands in the document preamble:</para>
+<para><emphasis role='bold'>\usepackage[tableposition=top]{caption}</emphasis></para>
+<para><emphasis role='bold'>\captionsetup[figure]{labelfont={tt}, textfont=it, indention=1cm,%</emphasis></para>
+</chapter>
+</book>
\ No newline at end of file
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index a409d20..8da67e3 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3350,6 +3350,7 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
 	vector<xml::EndFontTag> tagsToClose;
 
 	std::vector<docstring> generatedParagraphs;
+	DocBookFontState old_fs = fs;
 	odocstringstream os;
 	auto * xs = new XMLStream(os); // XMLStream has no copy constructor: to create a new object, the only solution
 	// is to hold a pointer to the XMLStream (xs = XMLStream(os) is not allowed once the first object is built).
@@ -3369,8 +3370,10 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
 			os = odocstringstream();
 			delete xs;
 			xs = new XMLStream(os);
-			if (!ignore_fonts)
+			if (!ignore_fonts) {
 				font_old = outerfont.fontInfo();
+				fs = old_fs;
+			}
 		}
 
 		// Determine which tags should be opened or closed regarding fonts.

commit 67784de1f95ca4bc3225e24778d715b2f8007c6d
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Fri Sep 11 00:44:49 2020 +0200

    XHTML: fix generation of many useless </section>.

diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp
index 7d9a69b..4892a35 100644
--- a/src/output_xhtml.cpp
+++ b/src/output_xhtml.cpp
@@ -611,20 +611,26 @@ void xhtmlParagraphs(Text const & text,
 
 		// Think about adding <section> and/or </section>s.
 		if (style.category() == from_utf8("Sectioning")) {
+			int level = style.toclevel;
+
 			// Need to close a previous section if it has the same level or a higher one (close <section> if opening a
-			// <h2> after a <h2>, <h3>, <h4>, <h5>, or <h6>). More examples:
+			// <h2> after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
 			//   - current: h2; back: h1; do not close any <section>
 			//   - current: h1; back: h2; close two <section> (first the <h2>, then the <h1>, so a new <h1> can come)
-			// The level (h1, h2, etc.) corresponds to style.toclevel.
-			while (! headerLevels.empty() && style.toclevel <= headerLevels.top()) {
+			while (!headerLevels.empty() && level <= headerLevels.top()) {
+				// Output the tag only if it corresponds to a legit section.
+				int stackLevel = headerLevels.top();
+				if (stackLevel != Layout::NOT_IN_TOC && level > 1) { // <h1> is the document title.
+					xs << xml::EndTag("section");
+					xs << xml::CR();
+				}
 				headerLevels.pop();
-				xs << xml::EndTag("section");
-				xs << xml::CR();
 			}
 
-			// Open the new one.
-			headerLevels.push(style.toclevel);
-			if (style.toclevel > 1) { // <h1> is the document title.
+			// Open the new section: first push it onto the stack, then output it in XHTML.
+			headerLevels.push(level);
+			// Some sectioning-like elements should not be output (such as FrontMatter).
+			if (level != Layout::NOT_IN_TOC && level > 1) { // <h1> is the document title.
 				xs << xml::StartTag("section");
 				xs << xml::CR();
 			}

commit f42ba13433877b9629725ff79accf2a04e650a04
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Fri Sep 11 00:39:41 2020 +0200

    XML: bad fix for a crash that only happened in XHTML.
    
    As an error is output, I suppose that this behaviour is OK.

diff --git a/src/xml.cpp b/src/xml.cpp
index 8e936f8..dda39a4 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -477,7 +477,8 @@ XMLStream &XMLStream::operator<<(xml::EndTag const &etag)
 						   + "' when other tags were pending. Last pending tag is `"
 						   + to_utf8(pending_tags_.back()->writeTag())
 						   + "'. Tag discarded.");
-				pending_tags_.erase(dit);
+				if (!pending_tags_.empty())
+					pending_tags_.erase(dit);
 				return *this;
 			}
 		}

commit 8f1cc760c8d0be1880e190a878e70bf7cb0c065b
Author: Scott Kostyshak <skostysh at lyx.org>
Date:   Wed Sep 2 22:48:23 2020 -0400

    DocBook: remove useless functions.

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index ce7e641..1e804ee 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -347,30 +347,6 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa
 }
 
 
-void openLabelTag(XMLStream & xs, Layout const & lay) // Mostly for definition lists.
-{
-	openTag(xs, lay.docbookitemlabeltag(), lay.docbookitemlabelattr(), lay.docbookitemlabeltagtype());
-}
-
-
-void closeLabelTag(XMLStream & xs, Layout const & lay)
-{
-	closeTag(xs, lay.docbookitemlabeltag(), lay.docbookitemlabeltagtype());
-}
-
-
-void openItemTag(XMLStream & xs, Layout const & lay)
-{
-	openTag(xs, lay.docbookitemtag(), lay.docbookitemattr(), lay.docbookitemtagtype());
-}
-
-
-void closeItemTag(XMLStream & xs, Layout const & lay)
-{
-	closeTag(xs, lay.docbookitemtag(), lay.docbookitemtagtype());
-}
-
-
 ParagraphList::const_iterator makeAny(Text const &,
 		                              Buffer const &,
 		                              XMLStream &,
@@ -656,17 +632,17 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text,
 		if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") {
 			if (style.labeltype == LABEL_MANUAL) {
 				// Only variablelist gets here (or similar items defined as an extension in the layout).
-				openLabelTag(xs, style);
+				openTag(xs, style.docbookitemlabeltag(), style.docbookitemlabelattr(), style.docbookitemlabeltagtype());
 				sep = 1 + par->firstWordDocBook(xs, runparams);
-				closeLabelTag(xs, style);
+				closeTag(xs, style.docbookitemlabeltag(), style.docbookitemlabeltagtype());
 			} else {
 				// Usual cases: maybe there is something specified at the layout level. Highly unlikely, though.
 				docstring const lbl = par->params().labelString();
 
 				if (!lbl.empty()) {
-					openLabelTag(xs, style);
+					openTag(xs, style.docbookitemlabeltag(), style.docbookitemlabelattr(), style.docbookitemlabeltagtype());
 					xs << lbl;
-					closeLabelTag(xs, style);
+					closeTag(xs, style.docbookitemlabeltag(), style.docbookitemlabeltagtype());
 				}
 			}
 		}

commit 7c66a8b188da530fede92b4437f0e56188375712
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Thu Sep 3 01:23:20 2020 +0200

    DocBook: avoid using isspace in StartTag::writeTag.
    
    This is the cause of crashes (on both Windows and Linux).

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index addf24a..ce7e641 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -429,16 +429,6 @@ void makeBibliography(
 }
 
 
-bool isNotOnlySpace(docstring const & str)
-{
-	for (auto const & c: str) {
-		if (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r')
-			return true;
-	}
-	return false;
-}
-
-
 void makeParagraph(
 		Text const & text,
 		Buffer const & buf,
@@ -531,7 +521,7 @@ void makeParagraph(
 	++nextpar;
 	auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end, special_case);
 	for (docstring const & parXML : pars) {
-		if (isNotOnlySpace(parXML)) {
+		if (xml::isNotOnlySpace(parXML)) {
 			if (open_par)
 				openParTag(xs, &*par, prevpar);
 
diff --git a/src/xml.cpp b/src/xml.cpp
index dd9790f..8e936f8 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -108,12 +108,9 @@ docstring StartTag::writeTag() const
 {
 	docstring output = '<' + tag_;
 	if (!attr_.empty()) {
-		docstring attributes = xml::escapeString(attr_, XMLStream::ESCAPE_NONE);
-		attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(),
-                                                          [](int c) {return !std::isspace(c);}));
-		if (!attributes.empty()) {
+		docstring attributes = xml::trimLeft(xml::escapeString(attr_, XMLStream::ESCAPE_NONE));
+		if (!attributes.empty())
 			output += ' ' + attributes;
-		}
 	}
 	output += ">";
 	return output;
@@ -601,6 +598,28 @@ docstring xml::uniqueID(docstring const & label)
 }
 
 
+bool xml::isNotOnlySpace(docstring const & str)
+{
+	for (auto const & c: str) {
+		if (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r')
+		return true;
+	}
+	return false;
+}
+
+
+docstring xml::trimLeft(docstring const & str)
+{
+	size_t i = 0;
+	for (auto const & c: str) {
+		if (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r')
+			return str.substr(i, docstring::npos);
+		i++;
+	}
+	return str;
+}
+
+
 docstring xml::cleanID(docstring const & orig)
 {
 	// The standard xml:id only allows letters, digits, '-' and '.' in a name.
diff --git a/src/xml.h b/src/xml.h
index 52eeb22..d5b4233 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -160,6 +160,12 @@ docstring cleanID(docstring const &orig);
 /// returns a unique numeric ID
 docstring uniqueID(docstring const & label);
 
+/// determines whether a string only contains space characters
+bool isNotOnlySpace(docstring const & str);
+
+/// trims the string to the left, i.e. remove any space-like character at the beginning of the string
+docstring trimLeft(docstring const & str);
+
 struct FontTag;
 struct EndFontTag;
 

commit 13e8d503100b92d338a72131023f239e6e25ce96
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Thu Sep 3 00:48:55 2020 +0200

    DocBook: introduce Floating::docbookFloatType.
    
    This ensures that all comparisons for DocBook are made on the same normalised version of the float type. This cased a strange bug where <table> was output within <informaltable> for Linguistics Tableaux.

diff --git a/autotests/export/docbook/Linguistics.xml b/autotests/export/docbook/Linguistics.xml
index 688ee2d..e7d7875 100644
--- a/autotests/export/docbook/Linguistics.xml
+++ b/autotests/export/docbook/Linguistics.xml
@@ -140,7 +140,6 @@ EndPreamble</programlisting>
 <para>Wenn Sie allerdings Ihre Tableaux durch das Dokument hindurch nummerieren und ein eigenes Tableaux-Verzeichnis einrichten möchten, reichen die Bordmittel von LyX nicht aus. Auch hier hilft das Linguistikmodul. Wenn es ausgewählt ist, finden Sie unter <emphasis role='sans'>Einfügen&#x21D2;Gleitobjekte</emphasis> zusätzlich ein Tableau-Gleitobjekt (siehe Tableau&#xA0;<xref linkend="tab.Beispiel-Tableau" /> für ein Beispiel).</para>
 <table xml:id="tab.Beispiel-Tableau">
 <caption>Beispiel-Tableau</caption>
-<informaltable>
 <tbody>
 <tr>
 <td align='right' valign='top'>/atikap/</td>
@@ -205,7 +204,6 @@ EndPreamble</programlisting>
 <td align='center' valign='top'></td>
 </tr>
 </tbody>
-</informaltable>
 </table>
 
 <para>Bitte beachten Sie, dass die Legende in der Standardeinstellung immer unter dem Tableau ausgegeben wird, egal, wohin Sie sie im LyX-Arbeitsfenster setzen. Um die Legende über das Tableau zu setzen, müssen Sie den folgenden Code in <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;Präambel </emphasis>eingeben:</para>
diff --git a/src/Floating.cpp b/src/Floating.cpp
index 7ee042c..6ae52b4 100644
--- a/src/Floating.cpp
+++ b/src/Floating.cpp
@@ -44,6 +44,25 @@ Floating::Floating(string const & type, string const & placement,
 {}
 
 
+std::string Floating::docbookFloatType() const
+{
+	// TODO: configure this in the layouts?
+	if (floattype_ == "figure") {
+		return "figure";
+	} else if (floattype_ == "table" || floattype_ == "tableau") {
+		return "table";
+	} else if (floattype_ == "algorithm") {
+		// TODO: no good translation for now! Figures are the closest match, as they can contain text.
+		// Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
+		return "algorithm";
+	} else {
+		// If nothing matches, return something that will not be valid.
+		LYXERR0("Unrecognised float type: " + floattype_);
+		return "unknown";
+	}
+}
+
+
 string const & Floating::htmlAttrib() const
 {
 	if (html_attrib_.empty())
@@ -91,17 +110,17 @@ string const & Floating::docbookAttr() const
 string Floating::docbookTag(bool hasTitle) const
 {
 	// TODO: configure this in the layouts?
-	if (floattype_ == "figure") {
+	if (docbookFloatType() == "figure") {
 		return hasTitle ? "figure" : "informalfigure";
-	} else if (floattype_ == "table" || floattype_ == "tableau") {
+	} else if (docbookFloatType() == "table") {
 		return hasTitle ? "table" : "informaltable";
-	} else if (floattype_ == "algorithm") {
+	} else if (docbookFloatType() == "algorithm") {
 		// TODO: no good translation for now! Figures are the closest match, as they can contain text.
 		// Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
 		return "figure";
 	} else {
 		// If nothing matches, return something that will not be valid.
-		LYXERR0("Unrecognised float type: " + floattype_);
+		LYXERR0("Unrecognised float type: " + floattype());
 		return "float";
 	}
 }
diff --git a/src/Floating.h b/src/Floating.h
index 46816af..0a2eb50 100644
--- a/src/Floating.h
+++ b/src/Floating.h
@@ -44,6 +44,8 @@ public:
 	///
 	std::string const & floattype() const { return floattype_; }
 	///
+	std::string docbookFloatType() const;
+	///
 	std::string const & placement() const { return placement_; }
 	///
 	std::string const & ext() const {return ext_; }
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index 86bcf9d..981ba40 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -639,7 +639,7 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
 	// captions, they cannot appear at the end of the float, albeit LyX is happy with that).
 	OutputParams rpNoTitle = runparams;
 	rpNoTitle.docbook_in_float = true;
-	if (ftype.floattype() == "table")
+	if (ftype.docbookFloatType() == "table")
 		rpNoTitle.docbook_in_table = true;
 
 	// Organisation: <float> <title if any/> <contents without title/> </float>.

commit 55157ded667091fa41e08af6d32d1b8606cf476e
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Thu Sep 3 00:37:52 2020 +0200

    Fix two warnings in BufferView.

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 75d8a4e..e75bc5e 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -947,7 +947,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool const recenter)
 	TextMetrics & tm = d->text_metrics_[bot.text()];
 
 	pos_type const max_pit = pos_type(bot.text()->paragraphs().size() - 1);
-	int bot_pit = bot.pit();
+	pos_type bot_pit = bot.pit();
 	if (bot_pit > max_pit) {
 		// FIXME: Why does this happen?
 		LYXERR0("bottom pit is greater that max pit: "

commit 57bf09e00ab469d1941588a3d158f8c9520a57f8
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Thu Sep 3 00:23:31 2020 +0200

    DocBook: floats can no more override DocBookTag.
    
    This lead to a quite subtle bug. The major problem is that float tags
    depend on whether the LyX float has a title (formal) or nor (informal).
    This information cannot be encoded in the layout format as easily as a
    simple DocBookTag.

diff --git a/src/Floating.cpp b/src/Floating.cpp
index fe3c72c..7ee042c 100644
--- a/src/Floating.cpp
+++ b/src/Floating.cpp
@@ -30,7 +30,7 @@ Floating::Floating(string const & type, string const & placement,
 		   string const & listName, std::string const & listCmd,
 		   string const & refPrefix, std::string const & allowedplacement,
 		   string const & htmlTag, string const & htmlAttrib,
-		   docstring const & htmlStyle, string const & docbookTag,
+		   docstring const & htmlStyle,
 		   string const & docbookAttr, string const & docbookTagType,
            string const & required, bool usesfloat, bool ispredefined,
 		   bool allowswide, bool allowssideways)
diff --git a/src/Floating.h b/src/Floating.h
index 977958b..46816af 100644
--- a/src/Floating.h
+++ b/src/Floating.h
@@ -37,7 +37,7 @@ public:
 		 std::string const & listName, std::string const & listCmd,
 		 std::string const & refPrefix, std::string const & allowedplacement,
 		 std::string const & htmlType, std::string const & htmlClass,
-		 docstring const & htmlStyle, std::string const & docbookTag,
+		 docstring const & htmlStyle,
 		 std::string const & docbookAttr, std::string const & docbookTagType,
 		 std::string const & required, bool usesfloat, bool isprefined,
 		 bool allowswide, bool allowssideways);
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index e413403..2bb1a04 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -1574,7 +1574,7 @@ bool TextClass::readFloat(Lexer & lexrc)
 		}
 		Floating fl(type, placement, ext, within, style, name,
 			listname, listcommand, refprefix, allowed_placement,
-			htmltag, htmlattr, htmlstyle, docbooktag, docbookattr,
+			htmltag, htmlattr, htmlstyle, docbookattr,
 			docbooktagtype, required, usesfloat, ispredefined,
 	        allowswide, allowssideways);
 		floatlist_.newFloat(fl);

commit 8498a3643dbd24f3cb58181ccad38f3ff2a846d6
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Wed Sep 2 00:46:08 2020 +0200

    DocBook: better output with the Linguistics module.
    
    One issue left: <table> output within an <informaltable>, that does not make sense... I'm debugging it.

diff --git a/autotests/export/docbook/Linguistics.lyx b/autotests/export/docbook/Linguistics.lyx
new file mode 100644
index 0000000..39978c3
--- /dev/null
+++ b/autotests/export/docbook/Linguistics.lyx
@@ -0,0 +1,3209 @@
+#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 article
+\begin_preamble
+%% Kommentieren Sie das Folgende aus, um Tableaux-Ãœberschriften zu erzeugen:
+%\floatstyle{plaintop}
+%\restylefloat{tableau}
+
+% Rückwärtskompatibilität zu forest 1.x
+% Wenn Sie forest 2.0.1 oder neuer verwenden,
+% können Sie das Folgende löschen.
+\@ifpackageloaded{forest}{%
+  \@ifpackagelater{forest}{2016/02/20}{}{%
+    \forestset{
+      roof/.style={edge path={\noexpand\path[\forestoption{edge}]%
+          (.north west)--(!u.south)--(.north east)--cycle
+          \forestoption{edge label};
+        }
+      },
+      sn edges/.style={
+        for tree={parent anchor=south, child anchor=north},
+      },
+      linguistics preamble/.style={sn edges, baseline, for tree={align=center}}
+    }
+    \preto\forest at do{%
+      \forestOpreto{\forest at root}{given options}{linguistics preamble,}%
+    }
+  }
+}{}
+
+% Trennausnahmen
+\hyphenation{Dis-kurs-reprä-sen-ta-tions-struk-tur}
+\end_preamble
+\use_default_options false
+\begin_modules
+linguistics
+\end_modules
+\maintain_unincluded_children no
+\language ngerman
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "lmodern" "FreeSerif"
+\font_sans "default" "FreeSans"
+\font_typewriter "default" "FreeMono"
+\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 false
+\graphics default
+\default_output_format default
+\output_sync 0
+\bibtex_command default
+\index_command default
+\float_placement class
+\float_alignment class
+\paperfontsize default
+\spacing single
+\use_hyperref true
+\pdf_bookmarks true
+\pdf_bookmarksnumbered false
+\pdf_bookmarksopen false
+\pdf_bookmarksopenlevel 1
+\pdf_breaklinks false
+\pdf_pdfborder true
+\pdf_colorlinks false
+\pdf_backref false
+\pdf_pdfusetitle true
+\papersize default
+\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
+\index Stichwortverzeichnis
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style german
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\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 false
+\docbook_table_output 0
+\end_header
+
+\begin_body
+
+\begin_layout Title
+Linguistische Arbeiten mit \SpecialChar LyX
+
+\end_layout
+
+\begin_layout Author
+Jürgen Spitzmüller
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset CommandInset href
+LatexCommand href
+target "spitz at lyx.org"
+type "mailto:"
+literal "false"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Date
+21.04.2015
+\end_layout
+
+\begin_layout Abstract
+In diesem Text werden einige Funktionen von \SpecialChar LyX
+ vorgestellt, die spezifisch
+ auf die Bedürfnisse von Linguistinnen und Linguisten ausgerichtet sind.
+ Es wird gezeigt, wie nummerierte Beispiele, Interlinear-Glossierung, OT-Tableau
+x, semantische Auszeichnung, Strukturbäume, Diskursrepräsentationsstrukturen
+ und phonetische Notation (IPA) erzeugt werden können.
+\end_layout
+
+\begin_layout Section
+Voraussetzungen und Ziele
+\end_layout
+
+\begin_layout Standard
+Die meisten der hier beschriebenen Funktionen werden vom 
+\begin_inset Quotes gld
+\end_inset
+
+Linguistik
+\begin_inset Quotes grd
+\end_inset
+
+-Modul bereitgestellt, das seit Version 1.6.0 mit \SpecialChar LyX
+ mitgeliefert wird.
+ 
+\begin_inset Quotes gld
+\end_inset
+
+Module
+\begin_inset Quotes grd
+\end_inset
+
+ – das Konzept wurde ebenfalls mit \SpecialChar LyX
+ 1.6.0 eingeführt – sind Ergänzungsdateien,
+ welche die von der Dokumentklasse bereitgestellten Möglichkeiten zumeist
+ für sehr spezifische Aufgaben erweitern und die für jedes Dokument (egal
+ welcher Klasse) einfach ausgewählt werden können.
+ Um das Linguistik-Modul zu verwenden, gehen sie zu 
+\family sans
+Dokument\SpecialChar menuseparator
+Einstellungen\SpecialChar menuseparator
+Module
+\family default
+, wählen Sie 
+\begin_inset Quotes gld
+\end_inset
+
+Linguistik
+\begin_inset Quotes grd
+\end_inset
+
+ aus der Liste der verfügbaren Module und drücken auf den Knopf 
+\family sans
+Hinzufügen
+\family default
+ (so wie es für dieses Dokument bereits getan wurde).
+\end_layout
+
+\begin_layout Standard
+Grundsätzlich sollte das Modul in jeder von \SpecialChar LyX
+ unterstützten Dokumentklasse
+ funktionieren (falls nicht, informieren Sie bitte den Autor dieses Textes).
+ Allerdings müssen Sie, um alle Features nutzen zu können, die folgenden
+ \SpecialChar LaTeX
+-Pakete installiert haben:
+\end_layout
+
+\begin_layout Enumerate
+
+\emph on
+covington.sty
+\emph default
+ 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "covington"
+literal "true"
+
+\end_inset
+
+: Dieses Paket wird benötigt, um nummerierte Beispiele, Glossen und semantische
+ Auszeichnungen zu erzeugen.
+ Beachten Sie, dass mindestens Version 2.3 des Pakets erforderlich ist, um
+ alle Funktionen zu nutzen.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Auf Ihrem System installiert: 
+\begin_inset Info
+type  "package"
+arg   "covington"
+\end_inset
+
+.
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\emph on
+csquotes.sty
+\emph default
+ 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "csquotes"
+literal "true"
+
+\end_inset
+
+: Voraussetzung für den Textstil 
+\emph on
+Bedeutung
+\emph default
+ und für Glossen.
+ Das Paket erlaubt es, kontextsensible Anführungszeichen zu generieren (bspw.
+ je nach aktuell verwendeter Sprache).
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Auf Ihrem System installiert: 
+\begin_inset Info
+type  "package"
+arg   "csquotes"
+\end_inset
+
+.
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\emph on
+drs.sty
+\emph default
+ 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "drs"
+literal "true"
+
+\end_inset
+
+: Voraussetzung für Diskursrepräsentationsstrukturen.
+ Beachten Sie, dass mindestens Version 2.3 des Pakets 
+\emph on
+covington
+\emph default
+ erforderlich ist, um dies mit anderen Funktionen gemeinsam zu nutzen.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Auf Ihrem System installiert: 
+\begin_inset Info
+type  "package"
+arg   "drs"
+\end_inset
+
+.
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\emph on
+float.sty
+\emph default
+ 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "float"
+literal "true"
+
+\end_inset
+
+: Dieses Paket brauchen wir für die OT-Tableaux und das Tableaux-Verzeichnis.
+ Es sollte Bestandteil jeder \SpecialChar LaTeX
+-Distribution sein.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Auf Ihrem System installiert: 
+\begin_inset Info
+type  "package"
+arg   "float"
+\end_inset
+
+.
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\emph on
+forest.sty
+\emph default
+ 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "forest"
+literal "true"
+
+\end_inset
+
+: Dieses Paket wird zur Erzeugung von Strukturbäumen verwendet.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Auf Ihrem System installiert: 
+\begin_inset Info
+type  "package"
+arg   "forest"
+\end_inset
+
+.
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\emph on
+pict2e.sty
+\emph default
+ 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "pict2e"
+literal "true"
+
+\end_inset
+
+: Voraussetzung für 
+\emph on
+Duplex-Bedingungs-DRS
+\emph default
+.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Auf Ihrem System installiert: 
+\begin_inset Info
+type  "package"
+arg   "pict2e"
+\end_inset
+
+.
+\end_layout
+
+\end_deeper
+\begin_layout Section
+Nummerierte Beispiele
+\end_layout
+
+\begin_layout Standard
+Nummerierte Beispiele werden über die Absatzstil-Auswahlliste in der Werkzeuglei
+ste eingefügt.
+ Es gibt drei Varianten:
+\end_layout
+
+\begin_layout Numbered Example (multiline)
+Das ist ein mehrzeiliges Beispiel [Stil 
+\emph on
+Nummeriertes Beispiel (mehrere Zeilen)
+\emph default
+]
+\end_layout
+
+\begin_layout Numbered Example (multiline)
+Wie der Name sagt, kann es mehrere Absätze enthalten
+\end_layout
+
+\begin_layout Numbered Examples (consecutive)
+Das ist ein einzeiliges Beispiel
+\begin_inset CommandInset label
+LatexCommand label
+name "exa:Beispiel-einzeilig"
+
+\end_inset
+
+ [Stil 
+\emph on
+Nummeriertes Beispiel (konsekutiv)
+\emph default
+]
+\end_layout
+
+\begin_layout Numbered Examples (consecutive)
+Jeder Absatz wird in diesem Stil neu nummeriert
+\end_layout
+
+\begin_layout Subexample
+Dies ist ein Unterbeispiel
+\begin_inset CommandInset label
+LatexCommand label
+name "subsec:Unterbeispiel"
+
+\end_inset
+
+ [Stil 
+\emph on
+Unterbeispiel
+\emph default
+]
+\end_layout
+
+\begin_layout Subexample
+Und hier noch eines
+\end_layout
+
+\begin_layout Standard
+Querverweise auf Beispiele erzeugen Sie wie gewohnt: Sie fügen im Beispiel
+ eine Marke ein, und an der Stelle, an der der Querverweis erscheinen soll,
+ einen Verweis mittels 
+\family sans
+Einfügen\SpecialChar menuseparator
+Querverweis\SpecialChar ldots
+
+\family default
+ 
+\end_layout
+
+\begin_layout Standard
+Als kleine Demonstration verweisen wir hier auf die Beispiele 
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "exa:Beispiel-einzeilig"
+
+\end_inset
+
+ und 
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:Unterbeispiel"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+Wenn Sie die Nummerierung für einzelne Beispiele ändern möchten, verwenden
+ Sie 
+\family sans
+Einfügen\SpecialChar menuseparator
+Benutzerdef.
+ Nummerierung
+\family default
+.
+ Für globale Anpassungen bietet 
+\emph on
+covington
+\emph default
+ selbst Möglichkeiten.
+ Bitte konsultieren Sie das Handbuch des Pakets 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "covington"
+literal "false"
+
+\end_inset
+
+ für Einzelheiten.
+\end_layout
+
+\begin_layout Standard
+Ab Version 2.3 bietet 
+\emph on
+covingtons
+\emph default
+ subexamples-Umgebung ein optionales Argument (mit dem man Text zwischen
+ der Hauptnummer und dem ersten Unterbeispiel einfügen kann).
+ Dieses können Sie über 
+\family sans
+Einfügen\SpecialChar menuseparator
+Optionen für Unterbeispiele
+\family default
+ eingeben.
+ Bitte konsultieren Sie auch hier das Handbuch des Pakets 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "covington"
+literal "false"
+
+\end_inset
+
+ für Einzelheiten.
+\end_layout
+
+\begin_layout Section
+Interlinear-Glossierung
+\end_layout
+
+\begin_layout Standard
+Das Linguistikmodul stellt zwei Arten von Glossen zur Verfügung.
+ Beide sind über 
+\family sans
+Einfügen\SpecialChar menuseparator
+Spezifische Einfügung
+\family default
+ zugänglich.
+ Die 
+\emph on
+Interlinear-Glosse (2
+\begin_inset space ~
+\end_inset
+
+Zeilen)
+\emph default
+ besteht aus zwei Zeilen für das Glossenpaar (bestehend aus der Darstellung
+ in der zu beschreibenden Sprache und einer interlinearen Wort-zu-Wort-Ãœbersetzu
+ng) sowie einer weiteren Zeile für die freie Übersetzung, die 
+\emph on
+Interlinear-Glosse (3
+\begin_inset space ~
+\end_inset
+
+Zeilen)
+\emph default
+ bietet eine zusätzliche Zeile für Interlinear-Glossierung (diese dritte
+ Zeile wird zumeist für morphologische oder phonologische Angaben verwendet).
+ Die freie Übersetzung kann länger sein als eine Zeile, sie wird dann einfach
+ automatisch und korrekt umbrochen.
+ Die Version in der zu beschreibenden Sprache (erste Zeile der Glosse) wird
+ direkt in die Glosse-Einfügung geschrieben, alle anderen Teile der Glosse
+ in spezifische Unter-Einfügungen (
+\family sans
+Interlinear-Glosse
+\family default
+, bzw.
+ mit dreizeiligen Glossen: 
+\family sans
+Interlinear-Glosse (Zeile
+\begin_inset space ~
+\end_inset
+
+1)
+\family default
+ und 
+\family sans
+Interlinear-Glosse (Zeile
+\begin_inset space ~
+\end_inset
+
+2)
+\family default
+, sowie 
+\family sans
+Glossen-Ãœbersetzung
+\family default
+).
+ \SpecialChar LyX
+ fügt diese Unter-Einfügungen automatisch ein, wenn Sie eine neue Glosse
+ einfügen.
+ Sie können aber auch manuell eingefügt werden, und zwar über 
+\family sans
+Einfügen\SpecialChar menuseparator
+Glossen-Ãœbersetzung
+\family default
+ und 
+\family sans
+Einfügen\SpecialChar menuseparator
+Interlinear-Glosse
+\family default
+.
+ Ungeachtet wo Sie diese Untereinfügungen innerhalb der Glosse einfügen,
+ wird alles in der richtigen Reihenfolge ausgegeben.
+ Schließlich können Sie über 
+\family sans
+Einfügen\SpecialChar menuseparator
+Glossen-Optionen
+\family default
+ auch Glossen-Optionen eingeben.
+ Diese Optionen erlauben es Ihnen, die Darstellung der einzelnen Zeilen
+ zu verändern, eine Nummerierung oder vorangestellten Text hinzuzufügen.
+ Bitte konsultieren Sie das Handbuch des Pakets 
+\emph on
+covington 
+\emph default
+
+\begin_inset CommandInset citation
+LatexCommand cite
+key "covington"
+literal "false"
+
+\end_inset
+
+ für Einzelheiten.
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+Bitte beachten Sie, dass die Unterstützung für Glossen für \SpecialChar LyX
+ 2.4 komplett
+ überarbeitet wurde.
+ Nun werden die neuen und verbesserten Glossen-Makros verwendet, die 
+\emph on
+covington
+\emph default
+ seit der Version 2.0 anbietet.
+ Wegen der erheblichen Veränderungen können alte Glossen leider nicht in
+ die neuen konvertiert werden.
+ Statt dessen werden sie in ihrer ursprünglichen Form importiert (und als
+ 
+\family sans
+Lokales Format
+\family default
+ im Dokument gespeichert).
+ Umgekehrt werden neue Glossen in \SpecialChar TeX
+-Code exportier, wenn Sie in eine ältere
+ \SpecialChar LyX
+-Version exportieren.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Hier ist ein einfaches Beispiel für eine zweizeilige Glosse:
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Interlinear Gloss (2 Lines)
+status open
+
+\begin_layout Plain Layout
+C'est       un exemple simple
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+\begin_inset Flex GroupGlossedWords
+status open
+
+\begin_layout Plain Layout
+Dies ist
+\end_layout
+
+\end_inset
+
+ ein Beispiel einfach
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+Dies ist ein einfaches Beispiel
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\noindent
+Verwenden Sie 
+\family sans
+Bearbeiten\SpecialChar menuseparator
+Textstil\SpecialChar menuseparator
+Glossierte Wortgruppen
+\family default
+, um Mehrwortelemente zusammenzuhalten (alternativ können Sie auch im TeX-Modus
+ 
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
+{
+\end_layout
+
+\end_inset
+
+diese Wörter geschweift einklammern
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\end_inset
+
+).
+ Beachten Sie, dass Sie im \SpecialChar LyX
+-Fenster mehrere Leerzeichen nacheinander einfügen
+ können, um die Glossen dort schöner auszurichten.
+ Die Ausgabe wird davon nicht berührt.
+\end_layout
+
+\begin_layout Standard
+Hier ist eine dreizeilige Glosse.
+ Sie wird analog erzeugt:
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Interlinear Gloss (3 Lines)
+status open
+
+\begin_layout Plain Layout
+Hoc est aliud exemplum
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+n.sg.nom 3sg n.sg.nom n.sg.nom
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+Dies ist anderes Beispiel 
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:3
+status open
+
+\begin_layout Plain Layout
+Dies ist ein anderes Beispiel
+\end_layout
+
+\end_inset
+
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
+fsii={
+\backslash
+normalfont
+\backslash
+scshape}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Beachten Sie, wie wir hier mit Hilfe der Glossen-Optionen die zweite Zeile
+ in Kapitälchen ausgeben lassen.
+\end_layout
+
+\begin_layout Standard
+\noindent
+Wenn Sie nummerierte Glossen benötigen, fügen Sie die Glosse entweder einfach
+ in einen Absatz mit dem Format 
+\emph on
+Nummeriertes Beispiel
+\emph default
+ ein, so wie hier:
+\end_layout
+
+\begin_layout Numbered Examples (consecutive)
+\begin_inset Flex Interlinear Gloss (3 Lines)
+status open
+
+\begin_layout Plain Layout
+Mein Luftkissenfahrzeug ist voller  Aale
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+My    skeertuig                   is   vol      palings
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+My    hovercraft                 is 
+\begin_inset Flex GroupGlossedWords
+status open
+
+\begin_layout Plain Layout
+full of
+\end_layout
+
+\end_inset
+
+  eels
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:3
+status open
+
+\begin_layout Plain Layout
+Do you have matches?
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+oder verwenden Sie die Glossen-Option 
+\emph on
+ex
+\emph default
+:
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Interlinear Gloss (3 Lines)
+status open
+
+\begin_layout Plain Layout
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+ex
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+Mein Luftkissenfahrzeug ist voller  Aale
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+My    skeertuig                   is   vol      palings
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+My    hovercraft                 is 
+\begin_inset Flex GroupGlossedWords
+status open
+
+\begin_layout Plain Layout
+full of
+\end_layout
+
+\end_inset
+
+  eels
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:3
+status open
+
+\begin_layout Plain Layout
+Do you have matches?
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection*
+Tipps & Tricks
+\end_layout
+
+\begin_layout Subsubsection*
+Seitenumbrüche innerhalb von Glossen vermeiden
+\end_layout
+
+\begin_layout Standard
+In der Standardeinstellung können innerhalb von Glossen Seiten umbrochen
+ werden, was natürlich nicht erwünscht ist.
+ Um dies zu umgehen, können Sie in 
+\family sans
+Dokument\SpecialChar menuseparator
+Einstellungen\SpecialChar ldots
+\SpecialChar menuseparator
+Dokumentklasse\SpecialChar menuseparator
+Klassenoptionen\SpecialChar menuseparator
+Benutzerdefiniert
+\family default
+ die Option 
+\emph on
+noglossbreaks
+\emph default
+ eingeben; dies wird die meisten Umbrüche verhindern.
+ Wenn trotzdem welche vorkommen, können Sie Glossen in Boxen packen (über
+ 
+\family sans
+Einfügen\SpecialChar menuseparator
+Box\SpecialChar menuseparator
+Rahmenlos
+\family default
+).
+\end_layout
+
+\begin_layout Subsubsection*
+Fußnoten in Glossen
+\end_layout
+
+\begin_layout Standard
+Sie können zwar eine Fußnote in eine 
+\emph on
+Glosse 
+\emph default
+einfügen, dies führt aber zu einem LaTeX-Fehler.
+ Wenn Sie Fußnoten benötigen, schreiben Sie an der Stelle, an der das Fußnotenze
+ichen erscheinen soll, im TeX-Modus 
+\family typewriter
+
+\backslash
+footnotemark
+\family default
+ in die Glosse.
+ Direkt nach (und außerhalb) der Glosse schreiben Sie, ebenfalls im TeX-Modus,
+\family typewriter
+ 
+\backslash
+footnotetext{Die Fußnote ...}
+\family default
+.
+ Sollten Sie mehrere Fußnoten brauchen, geben Sie einfach mehrere dieser
+ Befehlspaare ein.
+\end_layout
+
+\begin_layout Subsubsection*
+Glossen (und Beispiele) in Beamer-Präsentationen
+\end_layout
+
+\begin_layout Standard
+Wenn Sie das Linguistik-Modul in einer Beamer-Präsentation verwenden wollen,
+ beachten Sie bitte folgendes:
+\end_layout
+
+\begin_layout Itemize
+Für Glossen müssen Sie in Beamer immer einen 
+\begin_inset Quotes gld
+\end_inset
+
+fragilen
+\begin_inset Quotes grd
+\end_inset
+
+ Rahmen verwenden.
+ 
+\end_layout
+
+\begin_layout Itemize
+Ältere Versionen des Pakets 
+\emph on
+covington
+\emph default
+ und die 
+\emph on
+Beamer
+\emph default
+-Klasse arbeiten von Haus aus nicht gut zusammen, da beide die Befehle 
+\family typewriter
+
+\backslash
+example
+\family default
+ und 
+\family typewriter
+
+\backslash
+examples
+\family default
+ zu definieren versuchen, was in diesen älteren Versionen eine \SpecialChar LaTeX
+-Fehlermeldung
+ erzeugt, sobald sie Glossen oder Beispiele einfügen.
+ Sie können das Problem beheben, indem Sie in 
+\family sans
+Dokument\SpecialChar menuseparator
+Einstellungen\SpecialChar menuseparator
+Lokales Format
+\family default
+ folgenden Code kopieren:
+\end_layout
+
+\begin_deeper
+\begin_layout Quote
+\begin_inset listings
+lstparams "basicstyle={\footnotesize\ttfamily},tabsize=4"
+inline false
+status open
+
+\begin_layout Plain Layout
+
+Provides covington 1
+\end_layout
+
+\begin_layout Plain Layout
+
+AddToPreamble
+\end_layout
+
+\begin_layout Plain Layout
+
+		
+\backslash
+let
+\backslash
+example
+\backslash
+relax
+\end_layout
+
+\begin_layout Plain Layout
+
+		
+\backslash
+let
+\backslash
+endexample
+\backslash
+relax
+\end_layout
+
+\begin_layout Plain Layout
+
+		
+\backslash
+let
+\backslash
+examples
+\backslash
+relax
+\end_layout
+
+\begin_layout Plain Layout
+
+		
+\backslash
+let
+\backslash
+endexamples
+\backslash
+relax
+\end_layout
+
+\begin_layout Plain Layout
+
+		
+\backslash
+usepackage{covington}
+\end_layout
+
+\begin_layout Plain Layout
+
+EndPreamble
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Drücken Sie 
+\begin_inset Quotes gld
+\end_inset
+
+Validieren
+\begin_inset Quotes grd
+\end_inset
+
+ und dann 
+\begin_inset Quotes gld
+\end_inset
+
+OK
+\begin_inset Quotes grd
+\end_inset
+
+.
+ Dies hat den Effekt, dass die Beispiel-Umgebungen von Beamer deaktiviert
+ werden (und also nicht mehr verwendet werden können), dafür können Sie
+ dann aber die des Linguistik-Moduls verwenden.
+\end_layout
+
+\begin_layout Standard
+Ab 
+\emph on
+covington
+\emph default
+ 1.1 besteht dieses Problem nicht mehr.
+\end_layout
+
+\end_deeper
+\begin_layout Section
+Tableaux für Optimalitätstheorie
+\end_layout
+
+\begin_layout Standard
+Die OT-Tableaux selbst können natürlich einfach als normale Tabellen eingegeben
+ werden (Spezifika wie gestrichelte Tabellenlinien und schattierte Tabellenzelle
+n, die man hierfür manchmal braucht, sind in 
+\family sans
+Hilfe\SpecialChar menuseparator
+Eingebettete Objekt
+\family default
+e beschrieben).
+ 
+\end_layout
+
+\begin_layout Standard
+Wenn Sie allerdings Ihre Tableaux durch das Dokument hindurch nummerieren
+ und ein eigenes Tableaux-Verzeichnis einrichten möchten, reichen die Bordmittel
+ von \SpecialChar LyX
+ nicht aus.
+ Auch hier hilft das Linguistikmodul.
+ Wenn es ausgewählt ist, finden Sie unter 
+\family sans
+Einfügen\SpecialChar menuseparator
+Gleitobjekte
+\family default
+ zusätzlich ein Tableau-Gleitobjekt (siehe Tableau
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "tab:Beispiel-Tableau"
+
+\end_inset
+
+ für ein Beispiel).
+\end_layout
+
+\begin_layout Standard
+\begin_inset Float tableau
+placement h
+alignment document
+wide false
+sideways false
+status open
+
+\begin_layout Plain Layout
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="5" columns="5">
+<features tabularvalignment="middle">
+<column alignment="right" valignment="top">
+<column alignment="center" valignment="top">
+<column alignment="center" valignment="top">
+<column alignment="center" valignment="top" special="|c">
+<column alignment="center" valignment="top">
+<row>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+/atikap/
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\noun on
+Onset
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\noun on
+NoCoda
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\noun on
+Dep
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\noun on
+Max
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Formula $\mbox{☞}$
+\end_inset
+
+ 
+\begin_inset Formula $\mbox{\textipa{P}}$
+\end_inset
+
+a.ti.ka
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+*
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+*
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+a.ti.ka
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+*!
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+*
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Formula $\mbox{\textipa{P}}$
+\end_inset
+
+a.ti.kap
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+*!
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+*
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+a.ti.kap
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+*!
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+*!
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+Beispiel-Tableau
+\begin_inset CommandInset label
+LatexCommand label
+name "tab:Beispiel-Tableau"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Bitte beachten Sie, dass die Legende in der Standardeinstellung immer unter
+ dem Tableau ausgegeben wird, egal, wohin Sie sie im \SpecialChar LyX
+-Arbeitsfenster setzen.
+ Um die Legende über das Tableau zu setzen, müssen Sie den folgenden Code
+ in 
+\family sans
+Dokument\SpecialChar menuseparator
+Einstellungen\SpecialChar menuseparator
+Präambel 
+\family default
+eingeben:
+\end_layout
+
+\begin_layout Quote
+\begin_inset listings
+lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}"
+inline false
+status open
+
+\begin_layout Plain Layout
+
+
+\backslash
+floatstyle{plaintop}
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+restylefloat{tableau}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Wenn Sie eine KOMA-Klasse verwenden, nehmen Sie statt dessen das Folgende
+ (welches im Kontext der KOMA-Klassen bessere Abstände erzeugt):
+\end_layout
+
+\begin_layout Quote
+\begin_inset listings
+lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}"
+inline false
+status open
+
+\begin_layout Plain Layout
+
+
+\backslash
+floatstyle{komaabove}
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+restylefloat{tableau}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Ein Verzeichnis der Tableaux geben Sie, wie bei normalen Tabellen auch,
+ über 
+\family sans
+Einfügen\SpecialChar menuseparator
+Liste\SpecialChar breakableslash
+Inhaltsverzeichnis
+\family default
+ ein.
+ Dies sieht dann so aus:
+\end_layout
+
+\begin_layout Standard
+\begin_inset FloatList tableau
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Semantische Auszeichnung (Textstile)
+\end_layout
+
+\begin_layout Standard
+Das Linguistikmodul stellt einige Textstile zur Verfügung, die in linguistischen
+ Arbeiten allgemein gebräuchlich sind:
+\end_layout
+
+\begin_layout Enumerate
+Konzept (in Kapitälchen): 
+\begin_inset Flex Concepts
+status collapsed
+
+\begin_layout Plain Layout
+Konzept
+\end_layout
+
+\end_inset
+
+ 
+\end_layout
+
+\begin_layout Enumerate
+Ausdruck (hervorgehoben): 
+\begin_inset Flex Expression
+status collapsed
+
+\begin_layout Plain Layout
+Ausdruck
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Enumerate
+Bedeutung (in einfachen Anführungszeichen): 
+\begin_inset Flex Meaning
+status collapsed
+
+\begin_layout Plain Layout
+Bedeutung
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Diese Textstile finden Sie unter 
+\family sans
+Bearbeiten\SpecialChar menuseparator
+Textstil
+\family default
+.
+ Der Vorteil solcher Stile gegenüber direkter Hervorhebung und Auszeichnung
+ ist vor allem der, dass sie alle (und nur die) damit markierten Textteile
+ leicht global verändern können.
+ Wenn Sie (oder Ihr Verlag) also etwa Ausdrücke doch fett gesetzt haben
+ wollen, geben Sie einfach den folgenden Code in 
+\family sans
+Dokument\SpecialChar menuseparator
+Einstellungen\SpecialChar menuseparator
+Präambel
+\family default
+ ein:
+\end_layout
+
+\begin_layout Quote
+\begin_inset listings
+lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}"
+inline false
+status open
+
+\begin_layout Plain Layout
+
+
+\backslash
+renewcommand
+\backslash
+lexp[1]{
+\backslash
+textbf{#1}}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Auf ähnliche Weise kann auch das Aussehen von 
+\emph on
+Konzept
+\emph default
+ (
+\family typewriter
+
+\backslash
+lcon
+\family default
+) und 
+\emph on
+Bedeutung
+\emph default
+ (
+\family typewriter
+
+\backslash
+lmean
+\family default
+) verändert werden.
+ Bitte konsultieren Sie das Handbuch des Pakets 
+\emph on
+covington
+\emph default
+ 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "covington"
+literal "false"
+
+\end_inset
+
+ für Einzelheiten.
+\end_layout
+
+\begin_layout Section
+Linguistische Strukturbäume
+\end_layout
+
+\begin_layout Standard
+Mittlerweile gibt es mehrere \SpecialChar LaTeX
+-Pakete, die bei der Erstellung von Strukturbäumen
+ helfen.
+ \SpecialChar LyX
+ unterstützt das Paket 
+\family sans
+forest
+\family default
+, welches hohe Flexibilität und Mächtigkeit mit einer intuitiven Syntax
+ vereint.
+ Das Linguistik-Modul enthält eine Strukturbaum-Einfügung, die unter 
+\family sans
+Einfügen\SpecialChar menuseparator
+Spezifische Einfügung
+\family default
+ zu finden ist.
+ Innerhalb dieser Einfügung können Sie die Klammernotation verwenden, die
+ das Paket 
+\family sans
+forest
+\family default
+ (wie auch andere Pakete, z.
+\begin_inset space \thinspace{}
+\end_inset
+
+B.
+ 
+\family sans
+qtree
+\family default
+) anbietet.
+\end_layout
+
+\begin_layout Standard
+Hier ist ein einfaches Beispiel:
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Structure Tree
+status open
+
+\begin_layout Plain Layout
+[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[D[einen]][NP[Brief]]] ]
+ ]
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\noindent
+Wenn Sie die PDF-Ausgabe ansehen, sehen Sie, dass die Notation
+\end_layout
+
+\begin_layout Quote
+
+\family typewriter
+\size footnotesize
+[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[D[einen]][NP[Brief]]]]]
+\end_layout
+
+\begin_layout Standard
+als Strukturbaum ausgegeben wird.
+ Um das Ergebnis bereits im \SpecialChar LyX
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+"=
+\end_layout
+
+\end_inset
+
+Eingabefenster zu sehen, können Sie die Strukturbaum-Einfügung einfach in
+ eine Vorschau-Einfügung (
+\family sans
+Einfügen\SpecialChar menuseparator
+Vorschau
+\family default
+) einbetten.
+ Wenn 
+\begin_inset Quotes gld
+\end_inset
+
+Sofortige Vorschau
+\begin_inset Quotes grd
+\end_inset
+
+ richtig eingerichtet und aktiviert ist, sollten Sie den Baum sofort sehen
+ (zur Bearbeitung klicken Sie einfach auf das Bild):
+\end_layout
+
+\begin_layout Standard
+\begin_inset Preview
+
+\begin_layout Standard
+\begin_inset Flex Structure Tree
+status open
+
+\begin_layout Plain Layout
+[VP [DP[Maria]] [V' [V[schickt]] [DP[Hans]] [DP[D[eine]][NP[Antwort]]] ]
+ ]
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\noindent
+Dächer (
+\begin_inset Quotes gld
+\end_inset
+
+roofs
+\begin_inset Quotes grd
+\end_inset
+
+) können mittels der Option 
+\begin_inset Quotes gld
+\end_inset
+
+roof
+\begin_inset Quotes grd
+\end_inset
+
+
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+\noindent
+Bitte beachten Sie, dass die Option 
+\begin_inset Quotes gld
+\end_inset
+
+roof
+\begin_inset Quotes grd
+\end_inset
+
+ erst ab Version 2.0 des Pakets 
+\family sans
+forest
+\family default
+ verfügbar ist.
+ Für frühere Versionen haben wir in den Vorspann dieses Dokuments Code eingefügt
+, die die Verwendung dennoch gestattet.
+ Wenn Ihre Version des Pakets 
+\family sans
+forest
+\family default
+ kleiner ist als 2.0 und Sie 
+\begin_inset Quotes gld
+\end_inset
+
+roof
+\begin_inset Quotes grd
+\end_inset
+
+ verwenden wollen, müssen Sie diesen Code in den Vorspann Ihres Dokuments
+ kopieren.
+ Statt dessen können Sie auch die alte Option 
+\begin_inset Quotes gld
+\end_inset
+
+triangle
+\begin_inset Quotes grd
+\end_inset
+
+ (statt 
+\begin_inset Quotes gld
+\end_inset
+
+roof
+\begin_inset Quotes grd
+\end_inset
+
+) verwenden.
+\end_layout
+
+\end_inset
+
+ erzeugt werden (beachten Sie, dass Kommata eine spezielle Bedeutung haben;
+ sie markieren Optionen):
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Structure Tree
+status open
+
+\begin_layout Plain Layout
+[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[einen weiteren Brief, roof]]
+ ] ]
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\noindent
+Um die Knoten des Baums besser auszurichten, verwenden Sie die Option 
+\begin_inset Quotes gld
+\end_inset
+
+tier
+\begin_inset Quotes grd
+\end_inset
+
+.
+ Alle Knoten, denen dieselbe 
+\begin_inset Quotes gld
+\end_inset
+
+tier
+\begin_inset Quotes grd
+\end_inset
+
+ (Ebene) zugewiesen wurde, werden in einer vertikalen Linie ausgerichtet.
+ Hier ist ein Beispiel:
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Structure Tree
+status open
+
+\begin_layout Plain Layout
+[VP [DP[Hans, tier=word]] [V' [V[schickt, tier=word]] [DP[Maria, tier=word]]
+ [DP[D[einen, tier=word]][NP[Brief, tier=word]]] ] ]
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\noindent
+Das Paket bietet viel mehr Möglichkeiten, wie bspw.
+ Bewegungspfeile und Dekorationen.
+ Sie können hier nicht eingehend besprochen werden.
+ Bitte konsultieren Sie die ausführliche Dokumentation des Pakets 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "forest"
+literal "true"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Section
+Diskursrepräsentationsstrukturen
+\end_layout
+
+\begin_layout Standard
+Das Linguistik-Modul stellt auch Einfügungen zur Erzeugung von Diskursrepräsenta
+tionsstrukturen (DRSen) in der Box-Notation von 
+\noun on
+Hans Kamps
+\noun default
+ 
+\emph on
+Diskursrepräsentationstheorie
+\emph default
+ zur Verfügung.
+ Diese Einfügungen finden Sie unter 
+\family sans
+Einfügen\SpecialChar menuseparator
+Spezifische Einfügung
+\family default
+.
+\end_layout
+
+\begin_layout Standard
+Eine einfache DRS erzeugen Sie mit der Einfügung 
+\family sans
+Diskursrepräsentationsstruktur
+\family default
+.
+ Eine DRS besteht aus (Diskurs-)
+\emph on
+Bedingungen
+\emph default
+, die direkt in die Einfügung geschrieben werden, uns den (u.
+\begin_inset space \thinspace{}
+\end_inset
+
+U.
+ leeren) (Diskurs-)
+\emph on
+Referenten
+\emph default
+ (bzw., im DRT-Jargon, dem 
+\emph on
+Universum
+\emph default
+), welche in die (automatisch eingefügte) Untereinfügung 
+\emph on
+Referenten
+\emph default
+ geschrieben werden.
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+Sollte diese nicht eingefügt werden, finden Sie sie unter 
+\family sans
+Einfügen\SpecialChar menuseparator
+DRS-Referenten
+\family default
+.
+ 
+\end_layout
+
+\end_inset
+
+ Zeilenwechsel müssen mittels 
+\begin_inset Info
+type  "shortcut"
+arg   "newline-insert newline"
+\end_inset
+
+ eingefügt werden.
+ Hier ist ein einfaches Beispiel:
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace defskip
+\end_inset
+
+
+\begin_inset Flex DRS
+status open
+
+\begin_layout Plain Layout
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+x
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+Esel(x)
+\begin_inset Newline newline
+\end_inset
+
+grün(x)
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace defskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+DRSen sind durch spezifische Layout-Anpassungen so gestaltet, dass Sie gut
+ auf der Seite platziert werden.
+ Die Variante 
+\family sans
+Diskursrepräsentationsstruktur (einfach)
+\family default
+ unterdrückt diese Anpassungen.
+ 
+\end_layout
+
+\begin_layout Standard
+Zusätzlich zu diesen einfachen DRSen werden die folgenden konditionalen
+ DRSen unterstützt (sie werden in der Regel in einfache eingebettet):
+\end_layout
+
+\begin_layout Enumerate
+Die 
+\family sans
+Implikative DRS
+\family default
+ repräsentiert eine konditionale (implikative) Satzkonstruktion der Form
+ 
+\emph on
+wenn S
+\begin_inset script subscript
+
+\begin_layout Plain Layout
+
+\emph off
+1
+\end_layout
+
+\end_inset
+
+, dann S
+\emph default
+
+\begin_inset script subscript
+
+\begin_layout Plain Layout
+2
+\end_layout
+
+\end_inset
+
+:
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+\begin_inset Flex IfThen-DRS
+status open
+
+\begin_layout Plain Layout
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+x
+\begin_inset space ~
+\end_inset
+
+y
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+Joseph(x)
+\begin_inset Newline newline
+\end_inset
+
+Esel(y)
+\begin_inset Newline newline
+\end_inset
+
+besitzen(x,y)
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+z
+\begin_inset space ~
+\end_inset
+
+w
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+z = x
+\begin_inset Newline newline
+\end_inset
+
+w = y
+\begin_inset Newline newline
+\end_inset
+
+füttern(z,w)
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+Die 
+\family sans
+Konditionale DRS
+\family default
+ ist eine allgemeinere Variante, bei der Sie selbst eine beliebige Bedingung
+ (statt der implikativen) spezifizieren können.
+ In die Untereinfügung 
+\family sans
+Bedingung
+\family default
+ können Sie ein beliebiges Symbol eingeben:
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+\begin_inset Flex Cond-DRS
+status open
+
+\begin_layout Plain Layout
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+x
+\begin_inset space ~
+\end_inset
+
+y
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+Joseph(x)
+\begin_inset Newline newline
+\end_inset
+
+Esel(y)
+\begin_inset Newline newline
+\end_inset
+
+besitzen(x,y)
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+\begin_inset Formula $\wedge\!\,$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+z
+\begin_inset space ~
+\end_inset
+
+w
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:3
+status open
+
+\begin_layout Plain Layout
+z = x
+\begin_inset Newline newline
+\end_inset
+
+w = y
+\begin_inset Newline newline
+\end_inset
+
+lieben(w,z)
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+Die 
+\family sans
+Duplex-Bedingungs-DRS
+\family default
+ können Sie für sog.
+ 
+\emph on
+Duplex-Bedingungen
+\emph default
+ verwenden:
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+\begin_inset Flex QDRS
+status open
+
+\begin_layout Plain Layout
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+x
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+x 
+\begin_inset Formula $\in$
+\end_inset
+
+ X
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+alle
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+x
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:3
+status open
+
+\begin_layout Plain Layout
+y
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument post:4
+status open
+
+\begin_layout Plain Layout
+Sekretärin(y)
+\begin_inset Newline newline
+\end_inset
+
+anstellen(x,y)
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+Die 
+\family sans
+Negierte DRS
+\family default
+ fügt eine DRS ein, der ein Negationszeichen vorangestellt ist:
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+\begin_inset Flex NegDRS
+status open
+
+\begin_layout Plain Layout
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+x
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+Esel(x)
+\begin_inset Newline newline
+\end_inset
+
+grün(x)
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_deeper
+\begin_layout Standard
+
+\family sans
+DRS mit Satz oberhalb
+\family default
+ schließlich tut, was es verspricht: Es setzt einen Satz über die Box-Repräsenta
+tion:
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace defskip
+\end_inset
+
+
+\begin_inset Flex SDRS
+status open
+
+\begin_layout Plain Layout
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+Ein Esel ist grün
+\end_layout
+
+\end_inset
+
+ 
+\end_layout
+
+\begin_layout Plain Layout
+\begin_inset Argument 2
+status open
+
+\begin_layout Plain Layout
+x
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+Esel(x)
+\begin_inset Newline newline
+\end_inset
+
+grün(x)
+\end_layout
+
+\end_inset
+
+
+\begin_inset VSpace defskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Das Paket 
+\emph on
+drs
+\emph default
+ bietet einige Möglichkeiten, um das Erscheinungsbild der DRS-Modelle anzupassen.
+ Bitte konsultieren Sie das Handbuch des Pakets 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "drs"
+literal "false"
+
+\end_inset
+
+ für Einzelheiten.
+\end_layout
+
+\begin_layout Section
+Phonetische Notation (IPA)
+\end_layout
+
+\begin_layout Standard
+Um phonetische Zeichen einzugeben, brauchen Sie das Linguistikmodul nicht.
+ IPA-Unterstützung ist mittlerweile eine Grundfunktion von \SpecialChar LyX
+.
+ Da IPA aber von Linguistinnen und Linguisten sehr häufig gebraucht wird,
+ wird die Verwendung der IPA-Funktion hier trotzdem (kurz) beschrieben.
+\end_layout
+
+\begin_layout Standard
+Um \SpecialChar LyX
+' IPA-Funktion mit klassischem \SpecialChar LaTeX
+ oder PDF\SpecialChar LaTeX
+ zu benutzen, müssen Sie das
+ Paket 
+\emph on
+tipa
+\emph default
+ 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "tipa"
+literal "true"
+
+\end_inset
+
+ installiert haben.
+ Es wird von \SpecialChar LyX
+ automatisch geladen, wenn Sie dem unten beschriebenen Vorgehen
+ folgen.
+ Wenn Sie Xe\SpecialChar TeX
+ oder Lua\SpecialChar TeX
+ verwenden (und 
+\begin_inset Quotes gld
+\end_inset
+
+Nicht-\SpecialChar TeX
+-Schriften verwenden
+\begin_inset Quotes grd
+\end_inset
+
+ in 
+\family sans
+Dokument\SpecialChar menuseparator
+Einstellungen\SpecialChar menuseparator
+Schriften
+\family default
+ aktiviert haben), wird statt dessen das Paket 
+\emph on
+xunicode
+\emph default
+ geladen, da 
+\emph on
+tipa
+\emph default
+ in diesem Fall nicht funktioniert.
+ Das Paket 
+\emph on
+xunicode
+\emph default
+ emuliert die Ausgabe von 
+\emph on
+tipa
+\emph default
+, ist aber nicht perfekt, so dass die Ausgabe möglicherweise nicht wie erwartet
+ ist.
+ Außerdem müssen Sie in diesem Fall darauf achten, dass die Nicht-\SpecialChar TeX
+-Schrift
+ die IPA-Symbole auch enthält (empfehlenswert sind Schriften wie 
+\emph on
+CMU Serif
+\emph default
+ oder 
+\emph on
+SIL Doulos
+\emph default
+).
+ Sie können auch eine Schrift nur für IPA definieren, indem sie das Folgende
+ in 
+\family sans
+Dokument\SpecialChar menuseparator
+Einstellungen\SpecialChar menuseparator
+LaTeX-Vorspann
+\family default
+ eingeben:
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}"
+inline false
+status open
+
+\begin_layout Plain Layout
+
+
+\backslash
+AtBeginDocument{%
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+newfontfamily{
+\backslash
+ipafont}{CMU Serif}% oder eine ander Schriftart
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+def
+\backslash
+useTIPAfont{
+\backslash
+ipafont}
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\end_inset
+
+Für eine direkte Vorschau der IPA-Symbole im Arbeitsfenster sollten Sie
+ weiterhin (egal, welche der oben beschriebenen Ausgabeformate Sie verwenden)
+ das 
+\emph on
+preview-latex
+\emph default
+-Paket 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "preview"
+literal "true"
+
+\end_inset
+
+ installiert haben.
+\end_layout
+
+\begin_layout Standard
+Phonetische Zeichen werden in eine spezielle Umgebung eingegeben, die Sie
+ über 
+\family sans
+Einfügen\SpecialChar menuseparator
+Sonderzeichen\SpecialChar menuseparator
+Phonetische Symbole 
+\family default
+aktivieren.
+ Es wird ein kleiner umrahmter Eingabebereich eingefügt, in den Sie einzelne
+ Zeichen, Wörter und Wortfolgen sowie auch mehrere Absätze mit phonetischer
+ Notation eingeben können.
+ Wenn Sie in dem Eingabebereich sind, wird eine Symbolleiste aktiviert,
+ die die wichtigsten IPA-Symbole (nach den IPA-Kategorien sortiert) bereitstellt.
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+Es fehlt ein Symbol: der (2005 in das IPA aufgenommene) labiodentale Flap.
+ Dieses Zeichen unterstützt das 
+\emph on
+Tipa-
+\emph default
+Paket noch nicht; daher kann es auch nicht von LyX unterstützt werden.
+\end_layout
+
+\end_inset
+
+ Jeder Symbolbereich dieser Symbolleiste kann durch Klicken auf die gestrichelte
+ Linie abgetrennt werden.
+ Dadurch kann phonetische Notation recht komfortabel eingegeben werden:
+ 
+\begin_inset IPA
+
+\begin_layout Standard
+[ˈɛtva zo:]
+\end_layout
+
+\end_inset
+
+.
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+Wenn Sie ein diakritisches Zeichen einfügen möchten, müssen Sie das Diakritikum
+ 
+\emph on
+nach
+\emph default
+ dem Basiszeichen einfügen.
+ Das heißt, für 
+\begin_inset IPA
+
+\begin_layout Standard
+[d̥]
+\end_layout
+
+\end_inset
+
+ geben Sie zuerst 
+\family typewriter
+<d>
+\family default
+ ein und dann direkt danach das Diakritikum 
+\family typewriter
+<Stimmlos>
+\family default
+ von der Symbolleiste.
+ Wenn Sie nur ein Diakritikum eingeben möchten, können Sie das direkt nach
+ einem Leerzeichen tun, so wie hier: 
+\begin_inset IPA
+
+\begin_layout Standard
+ ̼
+\end_layout
+
+\end_inset
+
+ (
+\family typewriter
+=
+\begin_inset space ~
+\end_inset
+
+<Leerzeichen>+<Lingolabial>
+\family default
+).
+\end_layout
+
+\end_inset
+
+ Wenn
+\emph on
+ preview-latex
+\emph default
+ installiert ist und Sie außerdem in
+\family sans
+ Werkzeuge\SpecialChar menuseparator
+Einstellungen\SpecialChar ldots
+\SpecialChar menuseparator
+Grafik
+\family default
+ 
+\begin_inset Quotes gld
+\end_inset
+
+Sofortige Vorschau
+\begin_inset Quotes grd
+\end_inset
+
+ aktiviert haben, zeigt \SpecialChar LyX
+ eine WYSIWYG-Vorschau der Notation an, sobald der
+ Cursor den IPA-Bereich verlässt.
+ Alternativ zur Symbolleiste können Sie die Zeichen auch direkt mithilfe
+ der Kurznotation eingeben können, die im 
+\emph on
+tipa
+\emph default
+-Handbuch erläutert wird: hier eine 
+\begin_inset IPA
+
+\begin_layout Standard
+[kOst"pro:b@]
+\end_layout
+
+\end_inset
+
+ (
+\emph on
+tipa
+\emph default
+-Kurznotation: 
+\family typewriter
+[kOst"pro:b@
+\family default
+]).
+ Alternativ können Sie die meisten IPA-Zeichen auch über 
+\family sans
+Einfügen\SpecialChar menuseparator
+Sonderzeichen\SpecialChar menuseparator
+Symbole\SpecialChar ldots
+
+\family default
+ in das Eingabefeld eingeben oder sie aus einem anderen Dokument kopieren
+ und dort einfügen.
+ Die Ausgabe sollte immer identisch sein, egal welche Eingabemethode Sie
+ wählen.
+\end_layout
+
+\begin_layout Standard
+Bitte beachten Sie, dass Sie die meisten IPA-Zeichen über die zuletzt genannten
+ Methoden auch außerhalb des IPA-Eingabebereichs einfügen können: [zoː viː
+ hiːɐ̯].
+ In der Ausgabe werden diese Zeichen dann ebenfalls direkt in die korrekten
+ 
+\emph on
+tipa
+\emph default
+-Makros umgewandelt (lassen Sie es uns wissen, falls das nicht der Fall
+ ist).
+ Dieses Verfahren hat aber gravierende Nachteile gegenüber der IPA-Umgebung,
+ denn die direkte Eingabe resultiert in der Regel in unerwünschter Schriftmischu
+ng (die lateinischen Buchstaben werden aus der Grundschrift, die speziellen
+ IPA-Zeichen aber aus der IPA-Schrift genommen, und diese beiden Schriften
+ passen nicht notwendigerweise zusammen).
+ Innerhalb der IPA-Eingabeumgebung wird dagegen für alle Zeichen dieselbe
+ Schrift verwendet.
+ Deshalb sollten Sie, wenn Sie nicht nur Einzelzeichen eingeben, unbedingt
+ den IPA-Eingabebereich verwenden.
+\end_layout
+
+\begin_layout Section
+Weitere Informationen
+\end_layout
+
+\begin_layout Standard
+Mehr und ausführlichere Informationen über die Möglichkeiten des Einsatzes
+ von \SpecialChar LyX
+ für linguistische Zwecke finden Sie auf der (englischsprachigen) 
+\emph on
+Linguist\SpecialChar LyX
+
+\emph default
+-Seite auf dem \SpecialChar LyX
+-Wiki 
+\begin_inset CommandInset citation
+LatexCommand cite
+key "linguistlyx"
+literal "true"
+
+\end_inset
+
+.
+ Sie sind übrigens herzlich eingeladen, dort aktiv mitzuschreiben!
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "covington"
+literal "true"
+
+\end_inset
+
+Das covington-Paket: 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.ctan.org/tex-archive/macros/latex/contrib/covington/
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "csquotes"
+literal "true"
+
+\end_inset
+
+Das csquotes-Paket: 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.ctan.org/tex-archive/macros/latex/contrib/csquotes/
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "drs"
+literal "false"
+
+\end_inset
+
+ Das drs-Paket: 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+https://ctan.org/tex-archive/macros/latex/contrib/drs
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "enumitem"
+literal "true"
+
+\end_inset
+
+Das enumitem-Paket: 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.ctan.org/tex-archive/macros/latex/contrib/enumitem/
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "float"
+literal "true"
+
+\end_inset
+
+Das float-Paket: 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.ctan.org/tex-archive/macros/latex/contrib/float/
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "forest"
+literal "true"
+
+\end_inset
+
+Das forest-Paket: 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.ctan.org/tex-archive/graphics/pgf/contrib/forest
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "linguistlyx"
+literal "true"
+
+\end_inset
+
+Maria Gouskova, Stacia Hartleben und Jürgen Spitzmüller: Using \SpecialChar LyX
+ for Linguistic
+ Papers.
+ 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+https://wiki.lyx.org/LyX/LinguistLyX
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "pict2e"
+literal "false"
+
+\end_inset
+
+Das pict2e-Paket: 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+https://ctan.org/tex-archive/macros/latex/contrib/pict2e
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "preview"
+literal "true"
+
+\end_inset
+
+Das preview-latex-Paket: 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.ctan.org/tex-archive/macros/latex/contrib/preview/
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Bibliography
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "tipa"
+literal "true"
+
+\end_inset
+
+Das tipa-Paket und die zugehörigen Schriften: 
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+http://www.ctan.org/tex-archive/fonts/tipa/
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/docbook/Linguistics.xml b/autotests/export/docbook/Linguistics.xml
new file mode 100644
index 0000000..688ee2d
--- /dev/null
+++ b/autotests/export/docbook/Linguistics.xml
@@ -0,0 +1,339 @@
+<?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="de_DE" 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">
+<info>
+<title>Linguistische Arbeiten mit LyX</title>
+<author>
+<personname>Jürgen Spitzmüller<emphasis role='size_large'><link xlink:href="spitz at lyx.org"></link></emphasis></personname>
+</author>
+<date>21.04.2015</date>
+<abstract>
+<para>In diesem Text werden einige Funktionen von LyX vorgestellt, die spezifisch auf die Bedürfnisse von Linguistinnen und Linguisten ausgerichtet sind. Es wird gezeigt, wie nummerierte Beispiele, Interlinear-Glossierung, OT-Tableaux, semantische Auszeichnung, Strukturbäume, Diskursrepräsentationsstrukturen und phonetische Notation (IPA) erzeugt werden können.</para>
+</abstract>
+
+</info>
+<section>
+<title>Voraussetzungen und Ziele</title>
+<para>Die meisten der hier beschriebenen Funktionen werden vom „Linguistik“-Modul bereitgestellt, das seit Version 1.6.0 mit LyX mitgeliefert wird. „Module“ – das Konzept wurde ebenfalls mit LyX 1.6.0 eingeführt – sind Ergänzungsdateien, welche die von der Dokumentklasse bereitgestellten Möglichkeiten zumeist für sehr spezifische Aufgaben erweitern und die für jedes Dokument (egal welcher Klasse) einfach ausgewählt werden können. Um das Linguistik-Modul zu verwenden, gehen sie zu <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;Module</emphasis>, wählen Sie „Linguistik“ aus der Liste der verfügbaren Module und drücken auf den Knopf <emphasis role='sans'>Hinzufügen</emphasis> (so wie es für dieses Dokument bereits getan wurde).</para>
+<para>Grundsätzlich sollte das Modul in jeder von LyX unterstützten Dokumentklasse funktionieren (falls nicht, informieren Sie bitte den Autor dieses Textes). Allerdings müssen Sie, um alle Features nutzen zu können, die folgenden LaTeX-Pakete installiert haben:</para>
+<orderedlist>
+<listitem>
+<para><emphasis>covington.sty</emphasis> <biblioref endterm="covington" />: Dieses Paket wird benötigt, um nummerierte Beispiele, Glossen und semantische Auszeichnungen zu erzeugen. Beachten Sie, dass mindestens Version 2.3 des Pakets erforderlich ist, um alle Funktionen zu nutzen.</para>
+<itemizedlist>
+<listitem>
+<para>Auf Ihrem System installiert: nein.</para>
+</listitem>
+</itemizedlist>
+</listitem>
+<listitem>
+<para><emphasis>csquotes.sty</emphasis> <biblioref endterm="csquotes" />: Voraussetzung für den Textstil <emphasis>Bedeutung</emphasis> und für Glossen. Das Paket erlaubt es, kontextsensible Anführungszeichen zu generieren (bspw. je nach aktuell verwendeter Sprache).</para>
+<itemizedlist>
+<listitem>
+<para>Auf Ihrem System installiert: nein.</para>
+</listitem>
+</itemizedlist>
+</listitem>
+<listitem>
+<para><emphasis>drs.sty</emphasis> <biblioref endterm="drs" />: Voraussetzung für Diskursrepräsentationsstrukturen. Beachten Sie, dass mindestens Version 2.3 des Pakets <emphasis>covington</emphasis> erforderlich ist, um dies mit anderen Funktionen gemeinsam zu nutzen.</para>
+<itemizedlist>
+<listitem>
+<para>Auf Ihrem System installiert: nein.</para>
+</listitem>
+</itemizedlist>
+</listitem>
+<listitem>
+<para><emphasis>float.sty</emphasis> <biblioref endterm="float" />: Dieses Paket brauchen wir für die OT-Tableaux und das Tableaux-Verzeichnis. Es sollte Bestandteil jeder LaTeX-Distribution sein.</para>
+<itemizedlist>
+<listitem>
+<para>Auf Ihrem System installiert: nein.</para>
+</listitem>
+</itemizedlist>
+</listitem>
+<listitem>
+<para><emphasis>forest.sty</emphasis> <biblioref endterm="forest" />: Dieses Paket wird zur Erzeugung von Strukturbäumen verwendet.</para>
+<itemizedlist>
+<listitem>
+<para>Auf Ihrem System installiert: nein.</para>
+</listitem>
+</itemizedlist>
+</listitem>
+<listitem>
+<para><emphasis>pict2e.sty</emphasis> <biblioref endterm="pict2e" />: Voraussetzung für <emphasis>Duplex-Bedingungs-DRS</emphasis>.</para>
+<itemizedlist>
+<listitem>
+<para>Auf Ihrem System installiert: nein.</para>
+</listitem>
+</itemizedlist>
+</listitem>
+</orderedlist>
+</section>
+<section>
+<title>Nummerierte Beispiele</title>
+<para>Nummerierte Beispiele werden über die Absatzstil-Auswahlliste in der Werkzeugleiste eingefügt. Es gibt drei Varianten:</para>
+<informalexample role='numbered'>
+<para>Das ist ein mehrzeiliges Beispiel [Stil <emphasis>Nummeriertes Beispiel (mehrere Zeilen)</emphasis>]</para>
+<para>Wie der Name sagt, kann es mehrere Absätze enthalten</para>
+</informalexample>
+<informalexample role='consecutive'>
+<para>Das ist ein einzeiliges Beispiel<anchor xml:id="exa.Beispiel-einzeilig" /> [Stil <emphasis>Nummeriertes Beispiel (konsekutiv)</emphasis>]Jeder Absatz wird in diesem Stil neu nummeriert</para>
+</informalexample>
+<informalexample role='consecutive'>
+<para>Dies ist ein Unterbeispiel<anchor xml:id="subsec.Unterbeispiel" /> [Stil <emphasis>Unterbeispiel</emphasis>]Und hier noch eines</para>
+</informalexample>
+<para>Querverweise auf Beispiele erzeugen Sie wie gewohnt: Sie fügen im Beispiel eine Marke ein, und an der Stelle, an der der Querverweis erscheinen soll, einen Verweis mittels <emphasis role='sans'>Einfügen&#x21D2;Querverweis&#x2026;</emphasis> </para>
+<para>Als kleine Demonstration verweisen wir hier auf die Beispiele <xref linkend="exa.Beispiel-einzeilig" /> und <xref linkend="subsec.Unterbeispiel" />.</para>
+<para>Wenn Sie die Nummerierung für einzelne Beispiele ändern möchten, verwenden Sie <emphasis role='sans'>Einfügen&#x21D2;Benutzerdef. Nummerierung</emphasis>. Für globale Anpassungen bietet <emphasis>covington</emphasis> selbst Möglichkeiten. Bitte konsultieren Sie das Handbuch des Pakets <biblioref endterm="covington" /> für Einzelheiten.</para>
+<para>Ab Version 2.3 bietet <emphasis>covingtons</emphasis> subexamples-Umgebung ein optionales Argument (mit dem man Text zwischen der Hauptnummer und dem ersten Unterbeispiel einfügen kann). Dieses können Sie über <emphasis role='sans'>Einfügen&#x21D2;Optionen für Unterbeispiele</emphasis> eingeben. Bitte konsultieren Sie auch hier das Handbuch des Pakets <biblioref endterm="covington" /> für Einzelheiten.</para>
+</section>
+<section>
+<title>Interlinear-Glossierung</title>
+<para>Das Linguistikmodul stellt zwei Arten von Glossen zur Verfügung. Beide sind über <emphasis role='sans'>Einfügen&#x21D2;Spezifische Einfügung</emphasis> zugänglich. Die <emphasis>Interlinear-Glosse (2&#xA0;Zeilen)</emphasis> besteht aus zwei Zeilen für das Glossenpaar (bestehend aus der Darstellung in der zu beschreibenden Sprache und einer interlinearen Wort-zu-Wort-Übersetzung) sowie einer weiteren Zeile für die freie Übersetzung, die <emphasis>Interlinear-Glosse (3&#xA0;Zeilen)</emphasis> bietet eine zusätzliche Zeile für Interlinear-Glossierung (diese dritte Zeile wird zumeist für morphologische oder phonologische Angaben verwendet). Die freie Übersetzung kann länger sein als eine Zeile, sie wird dann einfach automatisch und korrekt umbrochen. Die Version in der zu beschreibenden Sprache (erste Zeile der Glosse) wird direkt in die Glosse-Einfügung geschrieben, alle anderen Teile der Glosse in spezifische Unter-Einfügungen (<emphasis role='sans'>Inter
 linear-Glosse</emphasis>, bzw. mit dreizeiligen Glossen: <emphasis role='sans'>Interlinear-Glosse (Zeile&#xA0;1)</emphasis> und <emphasis role='sans'>Interlinear-Glosse (Zeile&#xA0;2)</emphasis>, sowie <emphasis role='sans'>Glossen-Übersetzung</emphasis>). LyX fügt diese Unter-Einfügungen automatisch ein, wenn Sie eine neue Glosse einfügen. Sie können aber auch manuell eingefügt werden, und zwar über <emphasis role='sans'>Einfügen&#x21D2;Glossen-Übersetzung</emphasis> und <emphasis role='sans'>Einfügen&#x21D2;Interlinear-Glosse</emphasis>. Ungeachtet wo Sie diese Untereinfügungen innerhalb der Glosse einfügen, wird alles in der richtigen Reihenfolge ausgegeben. Schließlich können Sie über <emphasis role='sans'>Einfügen&#x21D2;Glossen-Optionen</emphasis> auch Glossen-Optionen eingeben. Diese Optionen erlauben es Ihnen, die Darstellung der einzelnen Zeilen zu verändern, eine Nummerierung oder vorangestellten Text hinzuzufügen. Bitte konsultieren Sie das Handb
 uch des Pakets <emphasis>covington </emphasis><biblioref endterm="covington" /> für Einzelheiten.<footnote>
+<para>Bitte beachten Sie, dass die Unterstützung für Glossen für LyX 2.4 komplett überarbeitet wurde. Nun werden die neuen und verbesserten Glossen-Makros verwendet, die <emphasis>covington</emphasis> seit der Version 2.0 anbietet. Wegen der erheblichen Veränderungen können alte Glossen leider nicht in die neuen konvertiert werden. Statt dessen werden sie in ihrer ursprünglichen Form importiert (und als <emphasis role='sans'>Lokales Format</emphasis> im Dokument gespeichert). Umgekehrt werden neue Glossen in TeX-Code exportier, wenn Sie in eine ältere LyX-Version exportieren.</para>
+</footnote></para>
+<para>Hier ist ein einfaches Beispiel für eine zweizeilige Glosse:</para>
+<para>C'est       un exemple simple</para>
+<para>Verwenden Sie <emphasis role='sans'>Bearbeiten&#x21D2;Textstil&#x21D2;Glossierte Wortgruppen</emphasis>, um Mehrwortelemente zusammenzuhalten (alternativ können Sie auch im TeX-Modus <!-- { -->
+diese Wörter geschweift einklammern<!-- } -->
+). Beachten Sie, dass Sie im LyX-Fenster mehrere Leerzeichen nacheinander einfügen können, um die Glossen dort schöner auszurichten. Die Ausgabe wird davon nicht berührt.</para>
+<para>Hier ist eine dreizeilige Glosse. Sie wird analog erzeugt:</para>
+<para>Hoc est aliud exemplum</para>
+<para>Beachten Sie, wie wir hier mit Hilfe der Glossen-Optionen die zweite Zeile in Kapitälchen ausgeben lassen.</para>
+<para>Wenn Sie nummerierte Glossen benötigen, fügen Sie die Glosse entweder einfach in einen Absatz mit dem Format <emphasis>Nummeriertes Beispiel</emphasis> ein, so wie hier:</para>
+<informalexample role='consecutive'>
+<para>Mein Luftkissenfahrzeug ist voller  Aale</para>
+</informalexample>
+<para>oder verwenden Sie die Glossen-Option <emphasis>ex</emphasis>:</para>
+<para>Mein Luftkissenfahrzeug ist voller  Aale</para>
+<bridgehead renderas="sect2">Tipps & Tricks</bridgehead>
+<bridgehead renderas="sect3">Seitenumbrüche innerhalb von Glossen vermeiden</bridgehead>
+<para>In der Standardeinstellung können innerhalb von Glossen Seiten umbrochen werden, was natürlich nicht erwünscht ist. Um dies zu umgehen, können Sie in <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x2026;&#x21D2;Dokumentklasse&#x21D2;Klassenoptionen&#x21D2;Benutzerdefiniert</emphasis> die Option <emphasis>noglossbreaks</emphasis> eingeben; dies wird die meisten Umbrüche verhindern. Wenn trotzdem welche vorkommen, können Sie Glossen in Boxen packen (über <emphasis role='sans'>Einfügen&#x21D2;Box&#x21D2;Rahmenlos</emphasis>).</para>
+<bridgehead renderas="sect3">Fußnoten in Glossen</bridgehead>
+<para>Sie können zwar eine Fußnote in eine <emphasis>Glosse </emphasis>einfügen, dies führt aber zu einem LaTeX-Fehler. Wenn Sie Fußnoten benötigen, schreiben Sie an der Stelle, an der das Fußnotenzeichen erscheinen soll, im TeX-Modus <code>\footnotemark</code> in die Glosse. Direkt nach (und außerhalb) der Glosse schreiben Sie, ebenfalls im TeX-Modus,<code> \footnotetext{Die Fußnote ...}</code>. Sollten Sie mehrere Fußnoten brauchen, geben Sie einfach mehrere dieser Befehlspaare ein.</para>
+<bridgehead renderas="sect3">Glossen (und Beispiele) in Beamer-Präsentationen</bridgehead>
+<para>Wenn Sie das Linguistik-Modul in einer Beamer-Präsentation verwenden wollen, beachten Sie bitte folgendes:</para>
+<itemizedlist>
+<listitem>
+<para>Für Glossen müssen Sie in Beamer immer einen „fragilen“ Rahmen verwenden. </para>
+</listitem>
+<listitem>
+<para>Ältere Versionen des Pakets <emphasis>covington</emphasis> und die <emphasis>Beamer</emphasis>-Klasse arbeiten von Haus aus nicht gut zusammen, da beide die Befehle <code>\example</code> und <code>\examples</code> zu definieren versuchen, was in diesen älteren Versionen eine LaTeX-Fehlermeldung erzeugt, sobald sie Glossen oder Beispiele einfügen. Sie können das Problem beheben, indem Sie in <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;Lokales Format</emphasis> folgenden Code kopieren:</para>
+<blockquote>
+<para><programlisting>Provides covington 1
+AddToPreamble
+		\let\example\relax
+		\let\endexample\relax
+		\let\examples\relax
+		\let\endexamples\relax
+		\usepackage{covington}
+EndPreamble</programlisting>
+</para>
+</blockquote>
+<para>Drücken Sie „Validieren“ und dann „OK“. Dies hat den Effekt, dass die Beispiel-Umgebungen von Beamer deaktiviert werden (und also nicht mehr verwendet werden können), dafür können Sie dann aber die des Linguistik-Moduls verwenden.</para>
+<para>Ab <emphasis>covington</emphasis> 1.1 besteht dieses Problem nicht mehr.</para>
+</listitem>
+</itemizedlist>
+</section>
+<section>
+<title>Tableaux für Optimalitätstheorie</title>
+<para>Die OT-Tableaux selbst können natürlich einfach als normale Tabellen eingegeben werden (Spezifika wie gestrichelte Tabellenlinien und schattierte Tabellenzellen, die man hierfür manchmal braucht, sind in <emphasis role='sans'>Hilfe&#x21D2;Eingebettete Objekt</emphasis>e beschrieben). </para>
+<para>Wenn Sie allerdings Ihre Tableaux durch das Dokument hindurch nummerieren und ein eigenes Tableaux-Verzeichnis einrichten möchten, reichen die Bordmittel von LyX nicht aus. Auch hier hilft das Linguistikmodul. Wenn es ausgewählt ist, finden Sie unter <emphasis role='sans'>Einfügen&#x21D2;Gleitobjekte</emphasis> zusätzlich ein Tableau-Gleitobjekt (siehe Tableau&#xA0;<xref linkend="tab.Beispiel-Tableau" /> für ein Beispiel).</para>
+<table xml:id="tab.Beispiel-Tableau">
+<caption>Beispiel-Tableau</caption>
+<informaltable>
+<tbody>
+<tr>
+<td align='right' valign='top'>/atikap/</td>
+<td align='center' valign='top'>Onset</td>
+<td align='center' valign='top'>NoCoda</td>
+<td align='center' valign='top'>Dep</td>
+<td align='center' valign='top'>Max</td>
+</tr>
+<tr>
+<td align='right' valign='top'><inlineequation>
+<alt role='tex'>\mbox{☞}</alt>
+ <m:math>
+ 
+ <m:mrow>
+  <m:mstyle class='mathbox'>☞
+  </m:mstyle>
+ </m:mrow>
+ </m:math>
+</inlineequation> <inlineequation>
+<alt role='tex'>\mbox{\textipa{P}}</alt>
+ <m:math>
+ 
+ <m:mrow>
+  <m:mstyle class='mathbox'>P
+  </m:mstyle>
+ </m:mrow>
+ </m:math>
+</inlineequation>a.ti.ka</td>
+<td align='center' valign='top'></td>
+<td align='center' valign='top'></td>
+<td align='center' valign='top'>*</td>
+<td align='center' valign='top'>*</td>
+</tr>
+<tr>
+<td align='right' valign='top'>a.ti.ka</td>
+<td align='center' valign='top'>*!</td>
+<td align='center' valign='top'></td>
+<td align='center' valign='top'></td>
+<td align='center' valign='top'>*</td>
+</tr>
+<tr>
+<td align='right' valign='top'><inlineequation>
+<alt role='tex'>\mbox{\textipa{P}}</alt>
+ <m:math>
+ 
+ <m:mrow>
+  <m:mstyle class='mathbox'>P
+  </m:mstyle>
+ </m:mrow>
+ </m:math>
+</inlineequation>a.ti.kap</td>
+<td align='center' valign='top'></td>
+<td align='center' valign='top'>*!</td>
+<td align='center' valign='top'>*</td>
+<td align='center' valign='top'></td>
+</tr>
+<tr>
+<td align='right' valign='top'>a.ti.kap</td>
+<td align='center' valign='top'>*!</td>
+<td align='center' valign='top'>*!</td>
+<td align='center' valign='top'></td>
+<td align='center' valign='top'></td>
+</tr>
+</tbody>
+</informaltable>
+</table>
+
+<para>Bitte beachten Sie, dass die Legende in der Standardeinstellung immer unter dem Tableau ausgegeben wird, egal, wohin Sie sie im LyX-Arbeitsfenster setzen. Um die Legende über das Tableau zu setzen, müssen Sie den folgenden Code in <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;Präambel </emphasis>eingeben:</para>
+<blockquote>
+<para><programlisting language="[LaTeX]TeX">\floatstyle{plaintop}
+\restylefloat{tableau}</programlisting>
+</para>
+</blockquote>
+<para>Wenn Sie eine KOMA-Klasse verwenden, nehmen Sie statt dessen das Folgende (welches im Kontext der KOMA-Klassen bessere Abstände erzeugt):</para>
+<blockquote>
+<para><programlisting language="[LaTeX]TeX">\floatstyle{komaabove}
+\restylefloat{tableau}</programlisting>
+</para>
+</blockquote>
+<para>Ein Verzeichnis der Tableaux geben Sie, wie bei normalen Tabellen auch, über <emphasis role='sans'>Einfügen&#x21D2;Liste&#x2044;Inhaltsverzeichnis</emphasis> ein. Dies sieht dann so aus:</para>
+</section>
+<section>
+<title>Semantische Auszeichnung (Textstile)</title>
+<para>Das Linguistikmodul stellt einige Textstile zur Verfügung, die in linguistischen Arbeiten allgemein gebräuchlich sind:</para>
+<orderedlist>
+<listitem>
+<para>Konzept (in Kapitälchen): Konzept </para>
+</listitem>
+<listitem>
+<para>Ausdruck (hervorgehoben): Ausdruck</para>
+</listitem>
+<listitem>
+<para>Bedeutung (in einfachen Anführungszeichen): Bedeutung</para>
+</listitem>
+</orderedlist>
+<para>Diese Textstile finden Sie unter <emphasis role='sans'>Bearbeiten&#x21D2;Textstil</emphasis>. Der Vorteil solcher Stile gegenüber direkter Hervorhebung und Auszeichnung ist vor allem der, dass sie alle (und nur die) damit markierten Textteile leicht global verändern können. Wenn Sie (oder Ihr Verlag) also etwa Ausdrücke doch fett gesetzt haben wollen, geben Sie einfach den folgenden Code in <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;Präambel</emphasis> ein:</para>
+<blockquote>
+<para><programlisting language="[LaTeX]TeX">\renewcommand\lexp[1]{\textbf{#1}}</programlisting>
+</para>
+</blockquote>
+<para>Auf ähnliche Weise kann auch das Aussehen von <emphasis>Konzept</emphasis> (<code>\lcon</code>) und <emphasis>Bedeutung</emphasis> (<code>\lmean</code>) verändert werden. Bitte konsultieren Sie das Handbuch des Pakets <emphasis>covington</emphasis> <biblioref endterm="covington" /> für Einzelheiten.</para>
+</section>
+<section>
+<title>Linguistische Strukturbäume</title>
+<para>Mittlerweile gibt es mehrere LaTeX-Pakete, die bei der Erstellung von Strukturbäumen helfen. LyX unterstützt das Paket <emphasis role='sans'>forest</emphasis>, welches hohe Flexibilität und Mächtigkeit mit einer intuitiven Syntax vereint. Das Linguistik-Modul enthält eine Strukturbaum-Einfügung, die unter <emphasis role='sans'>Einfügen&#x21D2;Spezifische Einfügung</emphasis> zu finden ist. Innerhalb dieser Einfügung können Sie die Klammernotation verwenden, die das Paket <emphasis role='sans'>forest</emphasis> (wie auch andere Pakete, z.&#x2009;B. <emphasis role='sans'>qtree</emphasis>) anbietet.</para>
+<para>Hier ist ein einfaches Beispiel:</para>
+<para>[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[D[einen]][NP[Brief]]] ] ]</para>
+<para>Wenn Sie die PDF-Ausgabe ansehen, sehen Sie, dass die Notation</para>
+<blockquote>
+<para><code><emphasis role='size_footnote'>[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[D[einen]][NP[Brief]]]]]</emphasis></code></para>
+</blockquote>
+<para>als Strukturbaum ausgegeben wird. Um das Ergebnis bereits im LyX<!-- "= -->
+Eingabefenster zu sehen, können Sie die Strukturbaum-Einfügung einfach in eine Vorschau-Einfügung (<emphasis role='sans'>Einfügen&#x21D2;Vorschau</emphasis>) einbetten. Wenn „Sofortige Vorschau“ richtig eingerichtet und aktiviert ist, sollten Sie den Baum sofort sehen (zur Bearbeitung klicken Sie einfach auf das Bild):</para>
+<para>[VP [DP[Maria]] [V' [V[schickt]] [DP[Hans]] [DP[D[eine]][NP[Antwort]]] ] ]</para>
+<para>Dächer („roofs“) können mittels der Option „roof“<footnote>
+<para>Bitte beachten Sie, dass die Option „roof“ erst ab Version 2.0 des Pakets <emphasis role='sans'>forest</emphasis> verfügbar ist. Für frühere Versionen haben wir in den Vorspann dieses Dokuments Code eingefügt, die die Verwendung dennoch gestattet. Wenn Ihre Version des Pakets <emphasis role='sans'>forest</emphasis> kleiner ist als 2.0 und Sie „roof“ verwenden wollen, müssen Sie diesen Code in den Vorspann Ihres Dokuments kopieren. Statt dessen können Sie auch die alte Option „triangle“ (statt „roof“) verwenden.</para>
+</footnote> erzeugt werden (beachten Sie, dass Kommata eine spezielle Bedeutung haben; sie markieren Optionen):</para>
+<para>[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[einen weiteren Brief, roof]] ] ]</para>
+<para>Um die Knoten des Baums besser auszurichten, verwenden Sie die Option „tier“. Alle Knoten, denen dieselbe „tier“ (Ebene) zugewiesen wurde, werden in einer vertikalen Linie ausgerichtet. Hier ist ein Beispiel:</para>
+<para>[VP [DP[Hans, tier=word]] [V' [V[schickt, tier=word]] [DP[Maria, tier=word]] [DP[D[einen, tier=word]][NP[Brief, tier=word]]] ] ]</para>
+<para>Das Paket bietet viel mehr Möglichkeiten, wie bspw. Bewegungspfeile und Dekorationen. Sie können hier nicht eingehend besprochen werden. Bitte konsultieren Sie die ausführliche Dokumentation des Pakets <biblioref endterm="forest" />.</para>
+</section>
+<section>
+<title>Diskursrepräsentationsstrukturen</title>
+<para>Das Linguistik-Modul stellt auch Einfügungen zur Erzeugung von Diskursrepräsentationsstrukturen (DRSen) in der Box-Notation von <personname>Hans Kamps</personname> <emphasis>Diskursrepräsentationstheorie</emphasis> zur Verfügung. Diese Einfügungen finden Sie unter <emphasis role='sans'>Einfügen&#x21D2;Spezifische Einfügung</emphasis>.</para>
+<para>Eine einfache DRS erzeugen Sie mit der Einfügung <emphasis role='sans'>Diskursrepräsentationsstruktur</emphasis>. Eine DRS besteht aus (Diskurs-)<emphasis>Bedingungen</emphasis>, die direkt in die Einfügung geschrieben werden, uns den (u.&#x2009;U. leeren) (Diskurs-)<emphasis>Referenten</emphasis> (bzw., im DRT-Jargon, dem <emphasis>Universum</emphasis>), welche in die (automatisch eingefügte) Untereinfügung <emphasis>Referenten</emphasis> geschrieben werden.<footnote>
+<para>Sollte diese nicht eingefügt werden, finden Sie sie unter <emphasis role='sans'>Einfügen&#x21D2;DRS-Referenten</emphasis>. </para>
+</footnote> Zeilenwechsel müssen mittels <keycap>Ctrl+Return</keycap> eingefügt werden. Hier ist ein einfaches Beispiel:</para>
+<para>
+Esel(x)grün(x)</para>
+<para>DRSen sind durch spezifische Layout-Anpassungen so gestaltet, dass Sie gut auf der Seite platziert werden. Die Variante <emphasis role='sans'>Diskursrepräsentationsstruktur (einfach)</emphasis> unterdrückt diese Anpassungen. </para>
+<para>Zusätzlich zu diesen einfachen DRSen werden die folgenden konditionalen DRSen unterstützt (sie werden in der Regel in einfache eingebettet):</para>
+<orderedlist>
+<listitem>
+<para>Die <emphasis role='sans'>Implikative DRS</emphasis> repräsentiert eine konditionale (implikative) Satzkonstruktion der Form <emphasis>wenn S<subscript>1</subscript>, dann S</emphasis><subscript>2</subscript>:</para>
+<para>Joseph(x)Esel(y)besitzen(x,y)</para>
+</listitem>
+<listitem>
+<para>Die <emphasis role='sans'>Konditionale DRS</emphasis> ist eine allgemeinere Variante, bei der Sie selbst eine beliebige Bedingung (statt der implikativen) spezifizieren können. In die Untereinfügung <emphasis role='sans'>Bedingung</emphasis> können Sie ein beliebiges Symbol eingeben:</para>
+<para>Joseph(x)Esel(y)besitzen(x,y)</para>
+</listitem>
+<listitem>
+<para>Die <emphasis role='sans'>Duplex-Bedingungs-DRS</emphasis> können Sie für sog. <emphasis>Duplex-Bedingungen</emphasis> verwenden:</para>
+<para>x <inlineequation>
+<alt role='tex'>\in</alt>
+ <m:math>
+ 
+ <m:mrow><m:mo>&#x2208;</m:mo>
+ </m:mrow>
+ </m:math>
+</inlineequation> X</para>
+</listitem>
+<listitem>
+<para>Die <emphasis role='sans'>Negierte DRS</emphasis> fügt eine DRS ein, der ein Negationszeichen vorangestellt ist:</para>
+<para>Esel(x)grün(x)</para>
+</listitem>
+</orderedlist>
+<para><emphasis role='sans'>DRS mit Satz oberhalb</emphasis> schließlich tut, was es verspricht: Es setzt einen Satz über die Box-Repräsentation:</para>
+<para>
+Esel(x)grün(x)
+</para>
+<para>Das Paket <emphasis>drs</emphasis> bietet einige Möglichkeiten, um das Erscheinungsbild der DRS-Modelle anzupassen. Bitte konsultieren Sie das Handbuch des Pakets <biblioref endterm="drs" /> für Einzelheiten.</para>
+</section>
+<section>
+<title>Phonetische Notation (IPA)</title>
+<para>Um phonetische Zeichen einzugeben, brauchen Sie das Linguistikmodul nicht. IPA-Unterstützung ist mittlerweile eine Grundfunktion von LyX. Da IPA aber von Linguistinnen und Linguisten sehr häufig gebraucht wird, wird die Verwendung der IPA-Funktion hier trotzdem (kurz) beschrieben.</para>
+<para>Um LyX' IPA-Funktion mit klassischem LaTeX oder PDFLaTeX zu benutzen, müssen Sie das Paket <emphasis>tipa</emphasis> <biblioref endterm="tipa" /> installiert haben. Es wird von LyX automatisch geladen, wenn Sie dem unten beschriebenen Vorgehen folgen. Wenn Sie XeTeX oder LuaTeX verwenden (und „Nicht-TeX-Schriften verwenden“ in <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;Schriften</emphasis> aktiviert haben), wird statt dessen das Paket <emphasis>xunicode</emphasis> geladen, da <emphasis>tipa</emphasis> in diesem Fall nicht funktioniert. Das Paket <emphasis>xunicode</emphasis> emuliert die Ausgabe von <emphasis>tipa</emphasis>, ist aber nicht perfekt, so dass die Ausgabe möglicherweise nicht wie erwartet ist. Außerdem müssen Sie in diesem Fall darauf achten, dass die Nicht-TeX-Schrift die IPA-Symbole auch enthält (empfehlenswert sind Schriften wie <emphasis>CMU Serif</emphasis> oder <emphasis>SIL Doulos</emphasis>). Sie können auch eine 
 Schrift nur für IPA definieren, indem sie das Folgende in <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;LaTeX-Vorspann</emphasis> eingeben:</para>
+<para><programlisting language="[LaTeX]TeX">\AtBeginDocument{%
+\newfontfamily{\ipafont}{CMU Serif}% oder eine ander Schriftart
+\def\useTIPAfont{\ipafont}
+}</programlisting>
+Für eine direkte Vorschau der IPA-Symbole im Arbeitsfenster sollten Sie weiterhin (egal, welche der oben beschriebenen Ausgabeformate Sie verwenden) das <emphasis>preview-latex</emphasis>-Paket <biblioref endterm="preview" /> installiert haben.</para>
+<para>Phonetische Zeichen werden in eine spezielle Umgebung eingegeben, die Sie über <emphasis role='sans'>Einfügen&#x21D2;Sonderzeichen&#x21D2;Phonetische Symbole </emphasis>aktivieren. Es wird ein kleiner umrahmter Eingabebereich eingefügt, in den Sie einzelne Zeichen, Wörter und Wortfolgen sowie auch mehrere Absätze mit phonetischer Notation eingeben können. Wenn Sie in dem Eingabebereich sind, wird eine Symbolleiste aktiviert, die die wichtigsten IPA-Symbole (nach den IPA-Kategorien sortiert) bereitstellt.<footnote>
+<para>Es fehlt ein Symbol: der (2005 in das IPA aufgenommene) labiodentale Flap. Dieses Zeichen unterstützt das <emphasis>Tipa-</emphasis>Paket noch nicht; daher kann es auch nicht von LyX unterstützt werden.</para>
+</footnote> Jeder Symbolbereich dieser Symbolleiste kann durch Klicken auf die gestrichelte Linie abgetrennt werden. Dadurch kann phonetische Notation recht komfortabel eingegeben werden: [ˈɛtva zo:].<footnote>
+<para>Wenn Sie ein diakritisches Zeichen einfügen möchten, müssen Sie das Diakritikum <emphasis>nach</emphasis> dem Basiszeichen einfügen. Das heißt, für [d̥] geben Sie zuerst <code><d></code> ein und dann direkt danach das Diakritikum <code><Stimmlos></code> von der Symbolleiste. Wenn Sie nur ein Diakritikum eingeben möchten, können Sie das direkt nach einem Leerzeichen tun, so wie hier:  ̼ (<code>=&#xA0;<Leerzeichen>+<Lingolabial></code>).</para>
+</footnote> Wenn<emphasis> preview-latex</emphasis> installiert ist und Sie außerdem in<emphasis role='sans'> Werkzeuge&#x21D2;Einstellungen&#x2026;&#x21D2;Grafik</emphasis> „Sofortige Vorschau“ aktiviert haben, zeigt LyX eine WYSIWYG-Vorschau der Notation an, sobald der Cursor den IPA-Bereich verlässt. Alternativ zur Symbolleiste können Sie die Zeichen auch direkt mithilfe der Kurznotation eingeben können, die im <emphasis>tipa</emphasis>-Handbuch erläutert wird: hier eine [kOst"pro:b@] (<emphasis>tipa</emphasis>-Kurznotation: <code>[kOst"pro:b@</code>]). Alternativ können Sie die meisten IPA-Zeichen auch über <emphasis role='sans'>Einfügen&#x21D2;Sonderzeichen&#x21D2;Symbole&#x2026;</emphasis> in das Eingabefeld eingeben oder sie aus einem anderen Dokument kopieren und dort einfügen. Die Ausgabe sollte immer identisch sein, egal welche Eingabemethode Sie wählen.</para>
+<para>Bitte beachten Sie, dass Sie die meisten IPA-Zeichen über die zuletzt genannten Methoden auch außerhalb des IPA-Eingabebereichs einfügen können: [zoː viː hiːɐ̯]. In der Ausgabe werden diese Zeichen dann ebenfalls direkt in die korrekten <emphasis>tipa</emphasis>-Makros umgewandelt (lassen Sie es uns wissen, falls das nicht der Fall ist). Dieses Verfahren hat aber gravierende Nachteile gegenüber der IPA-Umgebung, denn die direkte Eingabe resultiert in der Regel in unerwünschter Schriftmischung (die lateinischen Buchstaben werden aus der Grundschrift, die speziellen IPA-Zeichen aber aus der IPA-Schrift genommen, und diese beiden Schriften passen nicht notwendigerweise zusammen). Innerhalb der IPA-Eingabeumgebung wird dagegen für alle Zeichen dieselbe Schrift verwendet. Deshalb sollten Sie, wenn Sie nicht nur Einzelzeichen eingeben, unbedingt den IPA-Eingabebereich verwenden.</para>
+</section>
+<section>
+<title>Weitere Informationen</title>
+<para>Mehr und ausführlichere Informationen über die Möglichkeiten des Einsatzes von LyX für linguistische Zwecke finden Sie auf der (englischsprachigen) <emphasis>LinguistLyX</emphasis>-Seite auf dem LyX-Wiki <biblioref endterm="linguistlyx" />. Sie sind übrigens herzlich eingeladen, dort aktiv mitzuschreiben!</para>
+</section>
+<bibliography>
+<bibliomixed xml:id='covington'>Das covington-Paket: <link xlink:href="http://www.ctan.org/tex-archive/macros/latex/contrib/covington/">http://www.ctan.org/tex-archive/macros/latex/contrib/covington/</link>.</bibliomixed>
+<bibliomixed xml:id='csquotes'>Das csquotes-Paket: <link xlink:href="http://www.ctan.org/tex-archive/macros/latex/contrib/csquotes/">http://www.ctan.org/tex-archive/macros/latex/contrib/csquotes/</link>.</bibliomixed>
+<bibliomixed xml:id='drs'> Das drs-Paket: <link xlink:href="https://ctan.org/tex-archive/macros/latex/contrib/drs">https://ctan.org/tex-archive/macros/latex/contrib/drs</link>.</bibliomixed>
+<bibliomixed xml:id='enumitem'>Das enumitem-Paket: <link xlink:href="http://www.ctan.org/tex-archive/macros/latex/contrib/enumitem/">http://www.ctan.org/tex-archive/macros/latex/contrib/enumitem/</link>.</bibliomixed>
+<bibliomixed xml:id='float'>Das float-Paket: <link xlink:href="http://www.ctan.org/tex-archive/macros/latex/contrib/float/">http://www.ctan.org/tex-archive/macros/latex/contrib/float/</link>.</bibliomixed>
+<bibliomixed xml:id='forest'>Das forest-Paket: <link xlink:href="http://www.ctan.org/tex-archive/graphics/pgf/contrib/forest">http://www.ctan.org/tex-archive/graphics/pgf/contrib/forest</link>.</bibliomixed>
+<bibliomixed xml:id='linguistlyx'>Maria Gouskova, Stacia Hartleben und Jürgen Spitzmüller: Using LyX for Linguistic Papers. <link xlink:href="https://wiki.lyx.org/LyX/LinguistLyX">https://wiki.lyx.org/LyX/LinguistLyX</link>.</bibliomixed>
+<bibliomixed xml:id='pict2e'>Das pict2e-Paket: <link xlink:href="https://ctan.org/tex-archive/macros/latex/contrib/pict2e">https://ctan.org/tex-archive/macros/latex/contrib/pict2e</link></bibliomixed>
+<bibliomixed xml:id='preview'>Das preview-latex-Paket: <link xlink:href="http://www.ctan.org/tex-archive/macros/latex/contrib/preview/">http://www.ctan.org/tex-archive/macros/latex/contrib/preview/</link>.</bibliomixed>
+<bibliomixed xml:id='tipa'>Das tipa-Paket und die zugehörigen Schriften: <link xlink:href="http://www.ctan.org/tex-archive/fonts/tipa/">http://www.ctan.org/tex-archive/fonts/tipa/</link>.</bibliomixed>
+</bibliography>
+</article>
\ No newline at end of file
diff --git a/lib/layouts/linguistics.module b/lib/layouts/linguistics.module
index d272c25..bcfc370 100644
--- a/lib/layouts/linguistics.module
+++ b/lib/layouts/linguistics.module
@@ -82,6 +82,10 @@ Style Numbered_Example_(multiline)
 	EndFont
 	Requires	      covington
 	Category              Linguistics
+	DocBookWrapperTag     informalexample
+	DocBookWrapperAttr    role='numbered'
+	DocBookWrapperMergeWithPrevious  true
+	DocBookTag            para
 End
 
 
@@ -107,6 +111,10 @@ Style Numbered_Examples_(consecutive)
 		LabelString   "Custom Numbering|s"
 		Tooltip       "Customize the numeration"
 	EndArgument
+	DocBookWrapperTag     informalexample
+	DocBookWrapperAttr    role='consecutive'
+	DocBookWrapperMergeWithPrevious  true
+	DocBookTag            para
 End
 
 
diff --git a/src/Floating.cpp b/src/Floating.cpp
index a610c73..fe3c72c 100644
--- a/src/Floating.cpp
+++ b/src/Floating.cpp
@@ -90,9 +90,10 @@ string const & Floating::docbookAttr() const
 
 string Floating::docbookTag(bool hasTitle) const
 {
+	// TODO: configure this in the layouts?
 	if (floattype_ == "figure") {
 		return hasTitle ? "figure" : "informalfigure";
-	} else if (floattype_ == "table") {
+	} else if (floattype_ == "table" || floattype_ == "tableau") {
 		return hasTitle ? "table" : "informaltable";
 	} else if (floattype_ == "algorithm") {
 		// TODO: no good translation for now! Figures are the closest match, as they can contain text.
@@ -119,7 +120,7 @@ string const & Floating::docbookCaption() const
 	docbook_caption_ = "";
 	if (floattype_ == "figure") {
 		docbook_caption_ = "title";
-	} else if (floattype_ == "table") {
+	} else if (floattype_ == "table" || floattype_ == "tableau") {
 		docbook_caption_ = "caption";
 	} else if (floattype_ == "algorithm") {
 		// TODO: no good translation for now! Figures are the closest match, as they can contain text.
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 28d2e1e..addf24a 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -293,7 +293,8 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar
 	if (prevpar != nullptr) {
 		Layout const & prevlay = prevpar->layout();
 		if (prevlay.docbookwrappertag() != "NONE") {
-			if (prevlay.docbookwrappertag() == lay.docbookwrappertag())
+			if (prevlay.docbookwrappertag() == lay.docbookwrappertag() &&
+					prevlay.docbookwrapperattr() == lay.docbookwrapperattr())
 				openWrapper = !lay.docbookwrappermergewithprevious();
 			else
 				openWrapper = true;
@@ -329,7 +330,8 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa
 	if (nextpar != nullptr) {
 		Layout const & nextlay = nextpar->layout();
 		if (nextlay.docbookwrappertag() != "NONE") {
-			if (nextlay.docbookwrappertag() == lay.docbookwrappertag())
+			if (nextlay.docbookwrappertag() == lay.docbookwrappertag() &&
+					nextlay.docbookwrapperattr() == lay.docbookwrapperattr())
 				closeWrapper = !nextlay.docbookwrappermergewithprevious();
 			else
 				closeWrapper = true;

commit 4534899e7696f97069da8109dcfbe5765eeeec32
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Wed Sep 2 00:36:46 2020 +0200

    DocBook: fix crash with Linguistics example.
    
    This was due to Floating::docbookTag not returning anything with the floattype_ tableau. Another issue that happened with that document is that the standard library's isspace crashed for some characters. I therefore implemented a more efficient version of the part that required it, and inlined the definition of isspace (even though that part becomes irrespective of locale, but was that feature ever used?).

diff --git a/src/Floating.cpp b/src/Floating.cpp
index 19fbf5f..a610c73 100644
--- a/src/Floating.cpp
+++ b/src/Floating.cpp
@@ -98,6 +98,10 @@ string Floating::docbookTag(bool hasTitle) const
 		// TODO: no good translation for now! Figures are the closest match, as they can contain text.
 		// Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
 		return "figure";
+	} else {
+		// If nothing matches, return something that will not be valid.
+		LYXERR0("Unrecognised float type: " + floattype_);
+		return "float";
 	}
 }
 
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 087d5a9..28d2e1e 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -427,6 +427,16 @@ void makeBibliography(
 }
 
 
+bool isNotOnlySpace(docstring const & str)
+{
+	for (auto const & c: str) {
+		if (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r')
+			return true;
+	}
+	return false;
+}
+
+
 void makeParagraph(
 		Text const & text,
 		Buffer const & buf,
@@ -518,8 +528,8 @@ void makeParagraph(
 	auto nextpar = par;
 	++nextpar;
 	auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end, special_case);
-	for (auto & parXML : pars) {
-		if (!std::all_of(parXML.begin(), parXML.end(), ::isspace)) {
+	for (docstring const & parXML : pars) {
+		if (isNotOnlySpace(parXML)) {
 			if (open_par)
 				openParTag(xs, &*par, prevpar);
 

commit 0c7106744ffb43f99f0adf3318f4d4aab8a1277d
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Wed Sep 2 00:00:54 2020 +0200

    Fix a few warnings.

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 9dea24b..a409d20 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3860,8 +3860,8 @@ bool Paragraph::isHardHyphenOrApostrophe(pos_type pos) const
 	char_type const c = d->text_[pos];
 	if (c != '-' && c != '\'')
 		return false;
-	int nextpos = pos + 1;
-	int prevpos = pos > 0 ? pos - 1 : 0;
+	pos_type nextpos = pos + 1;
+	pos_type prevpos = pos > 0 ? pos - 1 : 0;
 	if ((nextpos == psize || isSpace(nextpos))
 		&& (pos == 0 || isSpace(prevpos)))
 		return false;
diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp
index b33cf00..4c6f17e 100644
--- a/src/insets/InsetNewline.cpp
+++ b/src/insets/InsetNewline.cpp
@@ -172,7 +172,7 @@ int InsetNewline::plaintext(odocstringstream & os,
 }
 
 
-void InsetNewline::docbook(XMLStream & xs, OutputParams const & runparams) const
+void InsetNewline::docbook(XMLStream &, OutputParams const &) const
 {
 	// New lines are handled by Paragraph::simpleDocBookOnePar.
 }
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 1f17351..087d5a9 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -471,7 +471,7 @@ void makeParagraph(
 	// Plain layouts must be ignored.
 	special_case |= buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars;
 	// Equations do not deserve their own paragraph (DocBook allows them outside paragraphs).
-	special_case |= nInsets == par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
+	special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
 		return inset.inset && inset.inset->asInsetMath();
 	});
 

commit ba6b9a2ba4e135e6a4cb8d2c45fbbfd3815c31f2
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 03:09:16 2020 +0200

    DocBook: do a little something for shapepar.

diff --git a/lib/layouts/shapepar.module b/lib/layouts/shapepar.module
index f5068dc..6b38cdf 100644
--- a/lib/layouts/shapepar.module
+++ b/lib/layouts/shapepar.module
@@ -35,41 +35,51 @@ Style "CD label"
 	ParSkip		0.4
 	Align		Block
 	LabelType	No_Label
+	DocBookWrapperTag  sidebar
+	DocBookWrapperAttr role="cd-label"
+	DocBookTag  para
 End
 
 Style "Circle"
 	CopyStyle	"CD label"
 	LatexName	circlepar
+	DocBookWrapperAttr role="circle"
 End
 
 Style "Diamond"
 	CopyStyle	"CD label"
 	LatexName	diamondpar
+	DocBookWrapperAttr role="diamond"
 End
 
 Style "Heart"
 	CopyStyle	"CD label"
 	LatexName	heartpar
+	DocBookWrapperAttr role="heart"
 End
 
 Style "Hexagon"
 	CopyStyle	"CD label"
 	LatexName	hexagonpar
+	DocBookWrapperAttr role="hexagon"
 End
 
 Style "Nut"
 	CopyStyle	"CD label"
 	LatexName	nutpar
+	DocBookWrapperAttr role="nut"
 End
 
 Style "Square"
 	CopyStyle	"CD label"
 	LatexName	squarepar
+	DocBookWrapperAttr role="square"
 End
 
 Style "Star"
 	CopyStyle	"CD label"
 	LatexName	starpar
+	DocBookWrapperAttr role="star"
 End
 
 # now the shapes defined in the .def files
@@ -77,41 +87,49 @@ End
 Style "Candle"
 	CopyStyle	"CD label"
 	LatexName	shapepar{\candle}
+	DocBookWrapperAttr role="candle"
 End
 
 Style "Drop down"
 	CopyStyle	"CD label"
 	LatexName	droppar
+	DocBookWrapperAttr role="drop-down"
 End
 
 Style "Drop up"
 	CopyStyle	"CD label"
 	LatexName	dropuppar
+	DocBookWrapperAttr role="drop-up"
 End
 
 Style "TeX"
 	CopyStyle	"CD label"
 	LatexName	shapepar{\TeXshape}
+	DocBookWrapperAttr role="tex"
 End
 
 Style "Triangle up"
 	CopyStyle	"CD label"
 	LatexName	triangleuppar
+	DocBookWrapperAttr role="triangle-up"
 End
 
 Style "Triangle down"
 	CopyStyle	"CD label"
 	LatexName	triangledownpar
+	DocBookWrapperAttr role="triangle-down"
 End
 
 Style "Triangle left"
 	CopyStyle	"CD label"
 	LatexName	triangleleftpar
+	DocBookWrapperAttr role="triangle-left"
 End
 
 Style "Triangle right"
 	CopyStyle	"CD label"
 	LatexName	trianglerightpar
+	DocBookWrapperAttr role="triangle-right"
 End
 
 # finally the low-level commands

commit bb58ae8c8a7c104d1f08e1cce820fb3e88880273
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 02:39:37 2020 +0200

    DocBook: implement theorems.
    
    This is a minimal implementation, as DocBook lacks a serious way of encoding all of this. Maybe a <formalpara> could do the trick, but I'd need to find a way to shoehorn a title through the styles (i.e. a first complete tag):
    
    Theorem: Bla bla
    
    <formalpara>
    <title>Theorem</title>
    <para>Bla bla</para>
    </formalpara>
    
    This would also only be a solution for single-paragraph things, as formalpara only allows one paragraph. Or a sidebar, but it's semantically very remote.

diff --git a/autotests/export/docbook/Additional_lyxcode.lyx b/autotests/export/docbook/Additional_lyxcode.lyx
index fe2d428..797e315 100644
--- a/autotests/export/docbook/Additional_lyxcode.lyx
+++ b/autotests/export/docbook/Additional_lyxcode.lyx
@@ -367,5 +367,169 @@ This section is somewhat out of date.
 
 \end_layout
 
+\begin_layout Section
+AMS \SpecialChar LaTeX
+
+\end_layout
+
+\begin_layout Standard
+These same environments are provided only in the starred versions by the
+ 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+Theorems (Starred)
+\end_layout
+
+\end_inset
+
+ module:
+\end_layout
+
+\begin_layout Theorem
+This is typically used for the statements of major results.
+ 
+\end_layout
+
+\begin_layout Corollary*
+This is used for statements which follow fairly directly from previous statement
+s.
+ Again, these can be major results.
+ 
+\end_layout
+
+\begin_layout Lemma
+These are smaller results needed to prove other statements.
+\end_layout
+
+\begin_layout Proposition
+These are less major results which (hopefully) add to the general theory
+ being discussed.
+\end_layout
+
+\begin_layout Conjecture
+These are statements provided without justification, which the author does
+ not know how to prove, but which seem to be true (to the author, at least).
+\end_layout
+
+\begin_layout Definition*
+Guess what this is for.
+ The font is different for this environment than for the previous ones.
+ 
+\end_layout
+
+\begin_layout Example*
+Used for examples illustrating proven results.
+\end_layout
+
+\begin_layout Problem
+It's not really known what this is for.
+ You should figure it out.
+\end_layout
+
+\begin_layout Exercise*
+Write a description for this one.
+\end_layout
+
+\begin_layout Remark
+This environment is also a type of theorem, usually a lesser sort of observation.
+\end_layout
+
+\begin_layout Claim*
+Often used in the course of giving a proof of a larger result.
+\end_layout
+
+\begin_layout Case
+Generally, these are used to break up long arguments, using specific instances
+ of some condition.
+ 
+\end_layout
+
+\begin_layout Case
+The numbering scheme for cases is on its own, not together with other numbered
+ statements.
+ 
+\end_layout
+
+\begin_layout Proof
+At the end of this environment, a QED symbol (usually a square, but it can
+ vary with different styles) is placed.
+ If you want to have other environments within this one—for example, Case
+ environments—and have the QED symbol appear only after them, then the other
+ environments need to be nested within the proof environment.
+ See the section 
+\emph on
+Nesting Environments
+\emph default
+ of the 
+\emph on
+User's Guide
+\emph default
+ for information on nesting.
+\end_layout
+
+\begin_layout Standard
+And these environments are provided by 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+Theorems (AMS-Extended)
+\end_layout
+
+\end_inset
+
+:
+\end_layout
+
+\begin_layout Criterion*
+A required condition.
+\end_layout
+
+\begin_layout Algorithm*
+A general procedure to be used.
+\end_layout
+
+\begin_layout Axiom*
+This is a property or statement taken as true within the system being discussed.
+\end_layout
+
+\begin_layout Condition*
+Sometimes used to state a condition assumed within the present context of
+ discussion.
+\end_layout
+
+\begin_layout Note*
+Similar to a Remark.
+\end_layout
+
+\begin_layout Notation*
+Used for the explanation of, yes, notation.
+\end_layout
+
+\begin_layout Summary
+Do we really need to tell you? 
+\end_layout
+
+\begin_layout Acknowledgement*
+Acknowledgement.
+\end_layout
+
+\begin_layout Conclusion*
+Sometimes used at the end of a long train of argument.
+\end_layout
+
+\begin_layout Fact
+Used in a way similar to Proposition, though perhaps lower on the scale.
+\end_layout
+
+\begin_layout Standard
+In addition, the AMS classes automatically provide the AMS \SpecialChar LaTeX
+ and AMS fonts
+ packages.
+ They need to be available on your system in order to use these environments.
+\end_layout
+
 \end_body
 \end_document
diff --git a/autotests/export/docbook/Additional_lyxcode.xml b/autotests/export/docbook/Additional_lyxcode.xml
index b677971..f42ac9f 100644
--- a/autotests/export/docbook/Additional_lyxcode.xml
+++ b/autotests/export/docbook/Additional_lyxcode.xml
@@ -36,5 +36,40 @@ This ...
 <para>This section is somewhat out of date. Need to describe default master documents and how children are opened when the master is. [[FIXME]]</para>
 </sidebar>
 </section>
+<section>
+<title>AMS LaTeX</title>
+<para>These same environments are provided only in the starred versions by the <code>Theorems (Starred)</code> module:</para>
+<para role='theorem'>This is typically used for the statements of major results. </para>
+<para role='corollary'>This is used for statements which follow fairly directly from previous statements. Again, these can be major results. </para>
+<para role='lemma'>These are smaller results needed to prove other statements.</para>
+<para role='proposition'>These are less major results which (hopefully) add to the general theory being discussed.</para>
+<para role='conjecture'>These are statements provided without justification, which the author does not know how to prove, but which seem to be true (to the author, at least).</para>
+<para role='definition'>Guess what this is for. The font is different for this environment than for the previous ones. </para>
+<informalexample>
+<para>Used for examples illustrating proven results.</para>
+</informalexample>
+<para role='problem'>It's not really known what this is for. You should figure it out.</para>
+<para role='exercise'>Write a description for this one.</para>
+<note role='theorem'>
+<para>This environment is also a type of theorem, usually a lesser sort of observation.</para>
+</note>
+<para role='claim'>Often used in the course of giving a proof of a larger result.</para>
+<para role='cases'>Generally, these are used to break up long arguments, using specific instances of some condition. The numbering scheme for cases is on its own, not together with other numbered statements. </para>
+<para role='proof'>At the end of this environment, a QED symbol (usually a square, but it can vary with different styles) is placed. If you want to have other environments within this one—for example, Case environments—and have the QED symbol appear only after them, then the other environments need to be nested within the proof environment. See the section <emphasis>Nesting Environments</emphasis> of the <emphasis>User's Guide</emphasis> for information on nesting.</para>
+<para>And these environments are provided by <code>Theorems (AMS-Extended)</code>:</para>
+<para role='criterion'>A required condition.</para>
+<para role='algorithm'>A general procedure to be used.</para>
+<para role='axiom'>This is a property or statement taken as true within the system being discussed.</para>
+<para role='condition'>Sometimes used to state a condition assumed within the present context of discussion.</para>
+<note role='theorem'>
+<para>Similar to a Remark.</para>
+</note>
+<para role='notation'>Used for the explanation of, yes, notation.</para>
+<para role='summary'>Do we really need to tell you? </para>
+<para role='acknowledgement'>Acknowledgement.</para>
+<para role='conclusion'>Sometimes used at the end of a long train of argument.</para>
+<para role='fact'>Used in a way similar to Proposition, though perhaps lower on the scale.</para>
+<para>In addition, the AMS classes automatically provide the AMS LaTeX and AMS fonts packages. They need to be available on your system in order to use these environments.</para>
+</section>
 </chapter>
 </book>
\ No newline at end of file
diff --git a/development/DocBookToDo b/development/DocBookToDo
index 39ca534..6b6ca34 100644
--- a/development/DocBookToDo
+++ b/development/DocBookToDo
@@ -17,4 +17,25 @@ TableRefs, TableComments: no mapping in DocBook, not really a way to add these t
 
 Clearly, with this kind of template, we're reaching the limits of such a system! Having a really good converter for all these cases would require a lot of very specific code. 
 
-More general: what the heck with appendices? It's not handled in the LyX way (Document > Start Appendix Here), but in a custom way. Making this work would solve some correctness issues with this template. 
\ No newline at end of file
+More general: what the heck with appendices? It's not handled in the LyX way (Document > Start Appendix Here), but in a custom way. Making this work would solve some correctness issues with this template. 
+
+
+
+Things specific to modules
+==========================
+
+AMS
+---
+
+Theorems and the like do not have counter parts in DocBook. Maybe a <formalpara> could do the trick, but I'd need to find a way to shoehorn a title through the styles (i.e. a first complete tag): 
+
+	LyX:
+		Theorem: Bla bla
+
+	DocBook:
+		<formalpara>
+			<title>Theorem</title>
+			<para>Bla bla</para>
+		</formalpara>
+
+This would also only be a solution for single-paragraph things, as formalpara only allows one paragraph. Or a sidebar, but it's semantically very remote. 
\ No newline at end of file
diff --git a/lib/layouts/theorems-ams-bytype.inc b/lib/layouts/theorems-ams-bytype.inc
index a306f15..fede0e8 100644
--- a/lib/layouts/theorems-ams-bytype.inc
+++ b/lib/layouts/theorems-ams-bytype.inc
@@ -110,6 +110,8 @@ Style Theorem
 		\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
 	EndBabelPreamble
 	Requires              amsthm
+	DocBookTag            para
+	DocBookAttr           role='theorem'
 End
 
 
@@ -128,6 +130,8 @@ Style Corollary
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='corollary'
 End
 
 
@@ -146,6 +150,8 @@ Style Lemma
 	  \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
 	EndBabelPreamble
 	LabelCounter          lemma
+	DocBookTag            para
+	DocBookAttr           role='lemma'
 End
 
 
@@ -164,6 +170,8 @@ Style Proposition
 	  \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
 	EndBabelPreamble
 	LabelCounter          proposition
+	DocBookTag            para
+	DocBookAttr           role='proposition'
 End
 
 
@@ -182,6 +190,8 @@ Style Conjecture
 	  \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
 	EndBabelPreamble
 	LabelCounter          conjecture
+	DocBookTag            para
+	DocBookAttr           role='conjecture'
 End
 
 
@@ -200,6 +210,8 @@ Style Fact
 	  \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
 	EndBabelPreamble
 	LabelCounter          fact
+	DocBookTag            para
+	DocBookAttr           role='fact'
 End
 
 
@@ -225,6 +237,8 @@ Style Definition
 	  \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
 	EndBabelPreamble
 	LabelCounter          definition
+	DocBookTag            para
+	DocBookAttr           role='definition'
 End
 
 
@@ -244,6 +258,9 @@ Style Example
 	  \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
 	EndBabelPreamble
 	LabelCounter          example
+	DocBookWrapperTag     informalexample
+	DocBookTag            para
+	DocBookAttr        ""
 End
 
 
@@ -263,6 +280,8 @@ Style Problem
 	  \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
 	EndBabelPreamble
 	LabelCounter          problem
+	DocBookTag            para
+	DocBookAttr           role='problem'
 End
 
 
@@ -282,6 +301,8 @@ Style Exercise
 	  \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
 	EndBabelPreamble
 	LabelCounter          exercise
+	DocBookTag            para
+	DocBookAttr           role='exercise'
 End
 
 
@@ -301,6 +322,8 @@ Style Solution
 		\addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}}
 	EndBabelPreamble
 	LabelCounter          solution
+	DocBookTag            para
+	DocBookAttr           role='solution'
 End
 
 
@@ -348,6 +371,9 @@ Style Claim
 	  \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
 	EndBabelPreamble
 	LabelCounter          claim
+	DocBookTag            para
+	DocBookAttr           role='claim'
+	DocBookItemTag        ""
 End
 
 Input theorems-case.inc
diff --git a/lib/layouts/theorems-ams-chap-bytype.inc b/lib/layouts/theorems-ams-chap-bytype.inc
index e4528f7..faaa2d0 100644
--- a/lib/layouts/theorems-ams-chap-bytype.inc
+++ b/lib/layouts/theorems-ams-chap-bytype.inc
@@ -129,6 +129,8 @@ Style Theorem
 		\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
 	EndBabelPreamble
 	Requires              amsthm
+	DocBookTag            para
+	DocBookAttr           role='theorem'
 End
 
 
@@ -151,6 +153,8 @@ Style Corollary
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='corollary'
 End
 
 
@@ -173,6 +177,8 @@ Style Lemma
 	  \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
 	EndBabelPreamble
 	LabelCounter          lemma
+	DocBookTag            para
+	DocBookAttr           role='lemma'
 End
 
 
@@ -195,6 +201,8 @@ Style Proposition
 	  \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
 	EndBabelPreamble
 	LabelCounter          proposition
+	DocBookTag            para
+	DocBookAttr           role='proposition'
 End
 
 
@@ -217,6 +225,8 @@ Style Conjecture
 	  \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
 	EndBabelPreamble
 	LabelCounter          conjecture
+	DocBookTag            para
+	DocBookAttr           role='conjecture'
 End
 
 
@@ -239,6 +249,8 @@ Style Fact
 	  \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
 	EndBabelPreamble
 	LabelCounter          fact
+	DocBookTag            para
+	DocBookAttr           role='fact'
 End
 
 
@@ -268,6 +280,8 @@ Style Definition
 	  \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
 	EndBabelPreamble
 	LabelCounter          definition
+	DocBookTag            para
+	DocBookAttr           role='definition'
 End
 
 
@@ -291,6 +305,9 @@ Style Example
 	  \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
 	EndBabelPreamble
 	LabelCounter          example
+	DocBookWrapperTag     informalexample
+	DocBookTag            para
+	DocBookAttr        ""
 End
 
 
@@ -314,6 +331,8 @@ Style Problem
 	  \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
 	EndBabelPreamble
 	LabelCounter          problem
+	DocBookTag            para
+	DocBookAttr           role='problem'
 End
 
 
@@ -337,6 +356,8 @@ Style Exercise
 	  \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
 	EndBabelPreamble
 	LabelCounter          exercise
+	DocBookTag            para
+	DocBookAttr           role='exercise'
 End
 
 
@@ -360,6 +381,8 @@ Style Solution
 		\addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}}
 	EndBabelPreamble
 	LabelCounter          solution
+	DocBookTag            para
+	DocBookAttr           role='solution'
 End
 
 
@@ -415,6 +438,9 @@ Style Claim
 	  \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
 	EndBabelPreamble
 	LabelCounter          claim
+	DocBookTag            para
+	DocBookAttr           role='claim'
+	DocBookItemTag        ""
 End
 
 
diff --git a/lib/layouts/theorems-ams-extended-bytype.module b/lib/layouts/theorems-ams-extended-bytype.module
index e031a74..c537def 100644
--- a/lib/layouts/theorems-ams-extended-bytype.module
+++ b/lib/layouts/theorems-ams-extended-bytype.module
@@ -87,6 +87,9 @@ Style Criterion
 	  \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}}
 	EndBabelPreamble
 	LabelCounter          criterion
+	DocBookTag            para
+	DocBookAttr           role='criterion'
+	DocBookItemTag        ""
 End
 
 Style Criterion*
@@ -103,6 +106,9 @@ Style Criterion*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='criterion'
+	DocBookItemTag        ""
 End
 
 
@@ -121,6 +127,9 @@ Style Algorithm
 	  \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}}
 	EndBabelPreamble
 	LabelCounter          algorithm
+	DocBookTag            para
+	DocBookAttr           role='algorithm'
+	DocBookItemTag        ""
 End
 
 
@@ -138,6 +147,9 @@ Style Algorithm*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='algorithm'
+	DocBookItemTag        ""
 End
 
 
@@ -156,6 +168,9 @@ Style Axiom
 	  \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}}
 	EndBabelPreamble
 	LabelCounter          axiom
+	DocBookTag            para
+	DocBookAttr           role='axiom'
+	DocBookItemTag        ""
 End
 
 
@@ -173,6 +188,9 @@ Style Axiom*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='axiom'
+	DocBookItemTag        ""
 End
 
 
@@ -191,6 +209,9 @@ Style Condition
 	  \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}}
 	EndBabelPreamble
 	LabelCounter          condition
+	DocBookTag            para
+	DocBookAttr           role='condition'
+	DocBookItemTag        ""
 End
 
 
@@ -208,6 +229,9 @@ Style Condition*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='condition'
+	DocBookItemTag        ""
 End
 
 
@@ -226,6 +250,8 @@ Style Note
 	  \addto\captions$$lang{\renewcommand{\notename}{_(Note)}}
 	EndBabelPreamble
 	LabelCounter          note
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
 
@@ -243,6 +269,8 @@ Style Note*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\notename}{_(Note)}}
 	EndBabelPreamble
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
 
@@ -261,6 +289,9 @@ Style Notation
 	  \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}}
 	EndBabelPreamble
 	LabelCounter          notation
+	DocBookTag            para
+	DocBookAttr           role='notation'
+	DocBookItemTag        ""
 End
 
 
@@ -278,6 +309,9 @@ Style Notation*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='notation'
+	DocBookItemTag        ""
 End
 
 
@@ -296,6 +330,9 @@ Style Summary
 	  \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}}
 	EndBabelPreamble
 	LabelCounter          summary
+	DocBookTag            para
+	DocBookAttr           role='summary'
+	DocBookItemTag        ""
 End
 
 
@@ -313,6 +350,9 @@ Style Summary*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='summary'
+	DocBookItemTag        ""
 End
 
 
@@ -331,6 +371,9 @@ Style Acknowledgement
 	  \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}
 	EndBabelPreamble
 	LabelCounter          acknowledgement
+	DocBookTag            para
+	DocBookAttr           role='acknowledgement'
+	DocBookItemTag        ""
 End
 
 
@@ -348,6 +391,9 @@ Style Acknowledgement*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='acknowledgement'
+	DocBookItemTag        ""
 End
 
 
@@ -366,6 +412,9 @@ Style Conclusion
 	  \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}}
 	EndBabelPreamble
 	LabelCounter          conclusion
+	DocBookTag            para
+	DocBookAttr           role='conclusion'
+	DocBookItemTag        ""
 End
 
 
@@ -383,6 +432,9 @@ Style Conclusion*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='conclusion'
+	DocBookItemTag        ""
 End
 
 
@@ -401,6 +453,9 @@ Style Assumption
 	  \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}}
 	EndBabelPreamble
 	LabelCounter          assumption
+	DocBookTag            para
+	DocBookAttr           role='assumption'
+	DocBookItemTag        ""
 End
 
 
@@ -418,6 +473,9 @@ Style Assumption*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='assumption'
+	DocBookItemTag        ""
 End
 
 Style Question
@@ -436,6 +494,9 @@ Style Question
 	  \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
 	EndBabelPreamble
 	LabelCounter          question
+	DocBookTag            para
+	DocBookAttr           role='question'
+	DocBookItemTag        ""
 End
 
 Style Question*
@@ -452,6 +513,9 @@ Style Question*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='question'
+	DocBookItemTag        ""
 End
 
 Input theorems-refprefix.inc
diff --git a/lib/layouts/theorems-ams-extended-chap-bytype.module b/lib/layouts/theorems-ams-extended-chap-bytype.module
index 435eb65..7252073 100644
--- a/lib/layouts/theorems-ams-extended-chap-bytype.module
+++ b/lib/layouts/theorems-ams-extended-chap-bytype.module
@@ -105,6 +105,9 @@ Style Criterion
 	  \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}}
 	EndBabelPreamble
 	LabelCounter          criterion
+	DocBookTag            para
+	DocBookAttr           role='criterion'
+	DocBookItemTag        ""
 End
 
 
@@ -122,6 +125,9 @@ Style Criterion*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='criterion'
+	DocBookItemTag        ""
 End
 
 
@@ -144,6 +150,9 @@ Style Algorithm
 	  \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}}
 	EndBabelPreamble
 	LabelCounter          algorithm
+	DocBookTag            para
+	DocBookAttr           role='algorithm'
+	DocBookItemTag        ""
 End
 
 
@@ -161,6 +170,9 @@ Style Algorithm*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='algorithm'
+	DocBookItemTag        ""
 End
 
 
@@ -183,6 +195,9 @@ Style Axiom
 	  \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}}
 	EndBabelPreamble
 	LabelCounter          axiom
+	DocBookTag            para
+	DocBookAttr           role='axiom'
+	DocBookItemTag        ""
 End
 
 
@@ -200,6 +215,9 @@ Style Axiom*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='axiom'
+	DocBookItemTag        ""
 End
 
 
@@ -222,6 +240,9 @@ Style Condition
 	  \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}}
 	EndBabelPreamble
 	LabelCounter          condition
+	DocBookTag            para
+	DocBookAttr           role='condition'
+	DocBookItemTag        ""
 End
 
 
@@ -239,6 +260,9 @@ Style Condition*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='condition'
+	DocBookItemTag        ""
 End
 
 
@@ -261,6 +285,8 @@ Style Note
 	  \addto\captions$$lang{\renewcommand{\notename}{_(Note)}}
 	EndBabelPreamble
 	LabelCounter          note
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
 
@@ -278,6 +304,8 @@ Style Note*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\notename}{_(Note)}}
 	EndBabelPreamble
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
 
@@ -300,6 +328,9 @@ Style Notation
 	  \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}}
 	EndBabelPreamble
 	LabelCounter          notation
+	DocBookTag            para
+	DocBookAttr           role='notation'
+	DocBookItemTag        ""
 End
 
 
@@ -317,6 +348,9 @@ Style Notation*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='notation'
+	DocBookItemTag        ""
 End
 
 
@@ -340,6 +374,9 @@ Style Summary
 	  \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}}
 	EndBabelPreamble
 	LabelCounter          summary
+	DocBookTag            para
+	DocBookAttr           role='summary'
+	DocBookItemTag        ""
 End
 
 
@@ -357,6 +394,9 @@ Style Summary*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='summary'
+	DocBookItemTag        ""
 End
 
 
@@ -379,6 +419,9 @@ Style Acknowledgement
 	  \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}
 	EndBabelPreamble
 	LabelCounter          acknowledgement
+	DocBookTag            para
+	DocBookAttr           role='acknowledgement'
+	DocBookItemTag        ""
 End
 
 
@@ -396,6 +439,9 @@ Style Acknowledgement*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='acknowledgement'
+	DocBookItemTag        ""
 End
 
 
@@ -418,6 +464,9 @@ Style Conclusion
 	  \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}}
 	EndBabelPreamble
 	LabelCounter          conclusion
+	DocBookTag            para
+	DocBookAttr           role='conclusion'
+	DocBookItemTag        ""
 End
 
 
@@ -435,6 +484,9 @@ Style Conclusion*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='conclusion'
+	DocBookItemTag        ""
 End
 
 
@@ -457,6 +509,9 @@ Style Assumption
 	  \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}}
 	EndBabelPreamble
 	LabelCounter          assumption
+	DocBookTag            para
+	DocBookAttr           role='assumption'
+	DocBookItemTag        ""
 End
 
 
@@ -474,6 +529,9 @@ Style Assumption*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='assumption'
+	DocBookItemTag        ""
 End
 
 Style Question
@@ -496,6 +554,9 @@ Style Question
 	  \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
 	EndBabelPreamble
 	LabelCounter          question
+	DocBookTag            para
+	DocBookAttr           role='question'
+	DocBookItemTag        ""
 End
 
 Style Question*
@@ -512,6 +573,9 @@ Style Question*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='question'
+	DocBookItemTag        ""
 End
 
 Input theorems-refprefix.inc
diff --git a/lib/layouts/theorems-ams-extended.module b/lib/layouts/theorems-ams-extended.module
index 0f33a90..f2c4cf0 100644
--- a/lib/layouts/theorems-ams-extended.module
+++ b/lib/layouts/theorems-ams-extended.module
@@ -48,6 +48,9 @@ Style Criterion
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='criterion'
+	DocBookItemTag        ""
 End
 
 Style Criterion*
@@ -64,6 +67,9 @@ Style Criterion*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='criterion'
+	DocBookItemTag        ""
 End
 
 
@@ -82,6 +88,9 @@ Style Algorithm
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='algorithm'
+	DocBookItemTag        ""
 End
 
 
@@ -99,6 +108,9 @@ Style Algorithm*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='algorithm'
+	DocBookItemTag        ""
 End
 
 
@@ -117,6 +129,9 @@ Style Axiom
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='axiom'
+	DocBookItemTag        ""
 End
 
 
@@ -134,6 +149,9 @@ Style Axiom*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='axiom'
+	DocBookItemTag        ""
 End
 
 
@@ -151,6 +169,9 @@ Style Condition
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='condition'
+	DocBookItemTag        ""
 End
 
 
@@ -168,6 +189,9 @@ Style Condition*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='condition'
+	DocBookItemTag        ""
 End
 
 
@@ -185,6 +209,8 @@ Style Note
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\notename}{_(Note)}}
 	EndBabelPreamble
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
 
@@ -202,6 +228,8 @@ Style Note*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\notename}{_(Note)}}
 	EndBabelPreamble
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
 
@@ -219,6 +247,9 @@ Style Notation
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='notation'
+	DocBookItemTag        ""
 End
 
 
@@ -236,6 +267,9 @@ Style Notation*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='notation'
+	DocBookItemTag        ""
 End
 
 
@@ -253,6 +287,9 @@ Style Summary
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='summary'
+	DocBookItemTag        ""
 End
 
 
@@ -270,6 +307,9 @@ Style Summary*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='summary'
+	DocBookItemTag        ""
 End
 
 
@@ -287,6 +327,9 @@ Style Acknowledgement
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='acknowledgement'
+	DocBookItemTag        ""
 End
 
 
@@ -304,6 +347,9 @@ Style Acknowledgement*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='acknowledgement'
+	DocBookItemTag        ""
 End
 
 
@@ -321,6 +367,9 @@ Style Conclusion
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='conclusion'
+	DocBookItemTag        ""
 End
 
 
@@ -338,6 +387,9 @@ Style Conclusion*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='conclusion'
+	DocBookItemTag        ""
 End
 
 
@@ -356,6 +408,9 @@ Style Assumption
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='assumption'
+	DocBookItemTag        ""
 End
 
 
@@ -373,6 +428,9 @@ Style Assumption*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='assumption'
+	DocBookItemTag        ""
 End
 
 Style Question
@@ -390,6 +448,9 @@ Style Question
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='question'
+	DocBookItemTag        ""
 End
 
 Style Question*
@@ -406,6 +467,9 @@ Style Question*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='question'
+	DocBookItemTag        ""
 End
 
 Input theorems-refprefix.inc
diff --git a/lib/layouts/theorems-ams.inc b/lib/layouts/theorems-ams.inc
index 99fcbf9..44cc806 100644
--- a/lib/layouts/theorems-ams.inc
+++ b/lib/layouts/theorems-ams.inc
@@ -69,6 +69,8 @@ Style Theorem
 	  \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
 	EndBabelPreamble
 	Requires              amsthm
+	DocBookTag            para
+	DocBookAttr           role='theorem'
 End
 
 
@@ -87,6 +89,8 @@ Style Corollary
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='corollary'
 End
 
 
@@ -105,6 +109,8 @@ Style Lemma
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='lemma'
 End
 
 
@@ -123,6 +129,8 @@ Style Proposition
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='proposition'
 End
 
 
@@ -141,6 +149,8 @@ Style Conjecture
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='conjecture'
 End
 
 
@@ -159,6 +169,8 @@ Style Fact
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='fact'
 End
 
 
@@ -184,6 +196,8 @@ Style Definition
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='definition'
 End
 
 
@@ -201,6 +215,9 @@ Style Example
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
 	EndBabelPreamble
+	DocBookWrapperTag     informalexample
+	DocBookTag            para
+	DocBookAttr           ""
 End
 
 
@@ -218,6 +235,8 @@ Style Problem
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='problem'
 End
 
 
@@ -235,6 +254,8 @@ Style Exercise
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='exercise'
 End
 
 
@@ -252,6 +273,8 @@ Style Solution
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='solution'
 End
 
 
@@ -297,6 +320,9 @@ Style Claim
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='claim'
+	DocBookItemTag        ""
 End
 
 Input theorems-case.inc
diff --git a/lib/layouts/theorems-bytype.inc b/lib/layouts/theorems-bytype.inc
index a61a4df..a40098b 100644
--- a/lib/layouts/theorems-bytype.inc
+++ b/lib/layouts/theorems-bytype.inc
@@ -66,6 +66,8 @@ Style Theorem
 		\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
 	EndBabelPreamble
 	Requires              amsthm
+	DocBookTag            para
+	DocBookAttr           role='theorem'
 End
 
 
@@ -84,6 +86,8 @@ Style Corollary
 		\addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
 	EndBabelPreamble
 	LabelCounter          corollary
+	DocBookTag            para
+	DocBookAttr           role='corollary'
 End
 
 
@@ -102,6 +106,8 @@ Style Lemma
 		\addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
 	EndBabelPreamble
 	LabelCounter          lemma
+	DocBookTag            para
+	DocBookAttr           role='lemma'
 End
 
 
@@ -120,6 +126,8 @@ Style Proposition
 		\addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
 	EndBabelPreamble
 	LabelCounter          proposition
+	DocBookTag            para
+	DocBookAttr           role='proposition'
 End
 
 
@@ -138,6 +146,8 @@ Style Conjecture
 		\addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
 	EndBabelPreamble
 	LabelCounter          conjecture
+	DocBookTag            para
+	DocBookAttr           role='conjecture'
 End
 
 
@@ -156,6 +166,8 @@ Style Fact
 		\addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
 	EndBabelPreamble
 	LabelCounter          fact
+	DocBookTag            para
+	DocBookAttr           role='fact'
 End
 
 
@@ -181,6 +193,8 @@ Style Definition
 		\addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
 	EndBabelPreamble
 	LabelCounter          definition  
+	DocBookTag            para
+	DocBookAttr           role='definition'
 End
 
 
@@ -200,6 +214,9 @@ Style Example
 		\addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
 	EndBabelPreamble
 	LabelCounter          example
+	DocBookWrapperTag     informalexample
+	DocBookTag            para
+	DocBookAttr        ""
 End
 
 
@@ -219,6 +236,8 @@ Style Problem
 		\addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
 	EndBabelPreamble
 	LabelCounter          problem
+	DocBookTag            para
+	DocBookAttr           role='problem'
 End
 
 
@@ -238,6 +257,8 @@ Style Exercise
 		\addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
 	EndBabelPreamble
 	LabelCounter          exercise
+	DocBookTag            para
+	DocBookAttr           role='exercise'
 End
 
 
@@ -257,6 +278,8 @@ Style Solution
 		\addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}}
 	EndBabelPreamble
 	LabelCounter          solution
+	DocBookTag            para
+	DocBookAttr           role='solution'
 End
 
 
@@ -304,6 +327,9 @@ Style Claim
 		\addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
 	EndBabelPreamble
 	LabelCounter          claim
+	DocBookTag            para
+	DocBookAttr           role='claim'
+	DocBookItemTag        ""
 End
 
 Input theorems-case.inc
diff --git a/lib/layouts/theorems-case.inc b/lib/layouts/theorems-case.inc
index cf85b48..1ee52a3 100644
--- a/lib/layouts/theorems-case.inc
+++ b/lib/layouts/theorems-case.inc
@@ -86,4 +86,6 @@ Style Case
     \addto\captions$$lang{\renewcommand{\casename}{_(Case)}}
   EndBabelPreamble
   RefPrefix OFF
+  DocBookTag            para
+  DocBookAttr           role='cases'
 End
diff --git a/lib/layouts/theorems-proof-std.inc b/lib/layouts/theorems-proof-std.inc
index 89c4173..8ba18cf 100644
--- a/lib/layouts/theorems-proof-std.inc
+++ b/lib/layouts/theorems-proof-std.inc
@@ -18,4 +18,6 @@ Style Proof
 		\fi
 	EndPreamble
 # No LangPreamble or BabelPreamble, since babel knows \proofname already.
+	DocBookTag            para
+	DocBookAttr           role='proof'
 End
diff --git a/lib/layouts/theorems-proof.inc b/lib/layouts/theorems-proof.inc
index 345ba38..949a35e 100644
--- a/lib/layouts/theorems-proof.inc
+++ b/lib/layouts/theorems-proof.inc
@@ -40,5 +40,7 @@ Style Proof
 	LabelFont
 	  Shape               Italic
 	EndFont
+	DocBookTag            para
+	DocBookAttr           role='proof'
 End
 
diff --git a/lib/layouts/theorems-starred.inc b/lib/layouts/theorems-starred.inc
index 4add989..fa02b21 100644
--- a/lib/layouts/theorems-starred.inc
+++ b/lib/layouts/theorems-starred.inc
@@ -67,6 +67,8 @@ Style Theorem*
 	  \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
 	EndBabelPreamble
 	Requires              amsthm
+	DocBookTag            para
+	DocBookAttr           role='theorem'
 End
 
 
@@ -84,6 +86,8 @@ Style Corollary*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='corollary'
 End
 
 
@@ -101,6 +105,8 @@ Style Lemma*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='lemma'
 End
 
 
@@ -118,6 +124,8 @@ Style Proposition*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='proposition'
 End
 
 
@@ -135,6 +143,8 @@ Style Conjecture*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='conjecture'
 End
 
 
@@ -152,6 +162,8 @@ Style Fact*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='fact'
 End
 
 
@@ -177,6 +189,8 @@ Style Definition*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='definition'
 End
 
 
@@ -194,6 +208,9 @@ Style Example*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
 	EndBabelPreamble
+	DocBookWrapperTag     informalexample
+	DocBookTag            para
+	DocBookAttr        ""
 End
 
 
@@ -211,6 +228,8 @@ Style Problem*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='problem'
 End
 
 
@@ -228,6 +247,8 @@ Style Exercise*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='exercise'
 End
 
 
@@ -245,6 +266,8 @@ Style Solution*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='solution'
 End
 
 
@@ -270,6 +293,8 @@ Style Remark*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}}
 	EndBabelPreamble
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
 
@@ -287,5 +312,8 @@ Style Claim*
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='claim'
+	DocBookItemTag        ""
 End
 
diff --git a/lib/layouts/theorems-without-preamble.inc b/lib/layouts/theorems-without-preamble.inc
index 80beb8e..43b8c0c 100644
--- a/lib/layouts/theorems-without-preamble.inc
+++ b/lib/layouts/theorems-without-preamble.inc
@@ -72,6 +72,8 @@ Style Theorem
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='theorem'
 End
 
 
@@ -89,6 +91,8 @@ Style Corollary
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='corollary'
 End
 
 
@@ -106,6 +110,8 @@ Style Lemma
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='lemma'
 End
 
 
@@ -123,6 +129,8 @@ Style Proposition
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='proposition'
 End
 
 
@@ -140,6 +148,8 @@ Style Prop
 	LabelFont
 	  Series	Medium
 	EndFont
+	DocBookTag            para
+	DocBookAttr           role='proposition'
 End
 
 
@@ -164,6 +174,8 @@ Style Conjecture
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='conjecture'
 End
 
 
@@ -181,6 +193,8 @@ Style Fact
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='fact'
 End
 
 
@@ -206,6 +220,8 @@ Style Definition
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='definition'
 End
 
 
@@ -224,6 +240,9 @@ Style Example
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
 	EndBabelPreamble
+	DocBookWrapperTag     informalexample
+	DocBookTag            para
+	DocBookAttr        ""
 End
 
 
@@ -243,6 +262,8 @@ Style Problem
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='problem'
 End
 
 
@@ -276,6 +297,8 @@ Style Prob
 	EndFont
 	AddToToc	thm
 	IsTocCaption	true
+	DocBookTag            para
+	DocBookAttr           role='problem'
 End
 
 
@@ -294,6 +317,8 @@ Style Solution
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='solution'
 End
 
 
@@ -308,6 +333,8 @@ Style Sol
 	  Tooltip	"Label of the corresponding problem"
 	  IsTocCaption true
 	EndArgument
+	DocBookTag            para
+	DocBookAttr           role='solution'
 End
 
 
@@ -326,6 +353,8 @@ Style Exercise
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='exercise'
 End
 
 
@@ -344,6 +373,8 @@ Style Remark
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}}
 	EndBabelPreamble
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
 
@@ -357,6 +388,9 @@ Style		Claim
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='claim'
+	DocBookItemTag        ""
 End
 
 
@@ -375,6 +409,8 @@ Style Case
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\casename}{_(Case)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='case'
 End
 
 
@@ -393,6 +429,8 @@ Style Property
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\propertyname}{_(Property)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='property'
 End
 
 
@@ -411,6 +449,8 @@ Style Question
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='question'
 End
 
 
@@ -429,5 +469,7 @@ Style Note
 	BabelPreamble
 	  \addto\captions$$lang{\renewcommand{\notename}{_(Note)}}
 	EndBabelPreamble
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
diff --git a/lib/layouts/theorems.inc b/lib/layouts/theorems.inc
index 9017ca6..822ee94 100644
--- a/lib/layouts/theorems.inc
+++ b/lib/layouts/theorems.inc
@@ -69,6 +69,8 @@ Style Theorem
 		\addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}}
 	EndBabelPreamble
 	Requires              amsthm
+	DocBookTag            para
+	DocBookAttr           role='theorem'
 End
 
 
@@ -87,6 +89,8 @@ Style Corollary
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='corollary'
 End
 
 
@@ -105,6 +109,8 @@ Style Lemma
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='lemma'
 End
 
 
@@ -123,6 +129,8 @@ Style Proposition
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='proposition'
 End
 
 
@@ -141,6 +149,8 @@ Style Conjecture
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='conjecture'
 End
 
 
@@ -159,6 +169,8 @@ Style Fact
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\factname}{_(Fact)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='fact'
 End
 
 
@@ -184,6 +196,8 @@ Style Definition
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='definition'
 End
 
 
@@ -201,6 +215,9 @@ Style Example
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\examplename}{_(Example)}}
 	EndBabelPreamble
+	DocBookWrapperTag     informalexample
+	DocBookTag            para
+	DocBookAttr        ""
 End
 
 
@@ -218,6 +235,8 @@ Style Problem
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='problem'
 End
 
 
@@ -235,6 +254,8 @@ Style Exercise
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='exercise'
 End
 
 
@@ -252,6 +273,8 @@ Style Solution
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='solution'
 End
 
 
@@ -278,6 +301,8 @@ Style Remark
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}}
 	EndBabelPreamble
+	DocBookTag            note
+	DocBookItemTag        para
 End
 
 
@@ -295,6 +320,9 @@ Style Claim
 	BabelPreamble
 		\addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}}
 	EndBabelPreamble
+	DocBookTag            para
+	DocBookAttr           role='claim'
+	DocBookItemTag        ""
 End
 
 Input theorems-case.inc

commit 239f0d66024b1508da19c3737967179e2c10f5fd
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 01:41:09 2020 +0200

    DocBook: several missing features for Additional.lyx.
    
    Includes: semantic markup (sorry about noun: Additional.lyx uses it to mark menus; there is something better in DocBook, but it looks like the LaTeX equivalent is really for person names), boxes, info layouts.

diff --git a/autotests/export/docbook/Additional_lyxcode.lyx b/autotests/export/docbook/Additional_lyxcode.lyx
new file mode 100644
index 0000000..fe2d428
--- /dev/null
+++ b/autotests/export/docbook/Additional_lyxcode.lyx
@@ -0,0 +1,371 @@
+#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 scrbook
+\begin_preamble
+% DO NOT ALTER THIS PREAMBLE!!!
+%
+% This preamble is designed to ensure that the manual prints
+% out as advertised. If you mess with this preamble,
+% parts of the manual may not print out as expected.  If you
+% have problems LaTeXing this file, please contact 
+% the documentation team
+% email: lyx-docs at lists.lyx.org
+
+% the pages of the TOC are numbered roman
+% and a PDF-bookmark for the TOC is added
+\pagenumbering{roman}
+\let\myTOC\tableofcontents
+\renewcommand{\tableofcontents}{%
+ \pdfbookmark[1]{\contentsname}{}
+ \myTOC
+ \cleardoublepage
+ \pagenumbering{arabic}}
+
+% extra space for tables
+\newcommand{\extratablespace}[1]{\noalign{\vskip#1}}
+\end_preamble
+\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading
+\use_default_options false
+\begin_modules
+logicalmkup
+theorems-ams
+theorems-ams-extended
+multicol
+shapepar
+\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 0
+\bibtex_command default
+\index_command default
+\paperfontsize 12
+\spacing single
+\use_hyperref true
+\pdf_title "LyX's Additional Features manual"
+\pdf_author "LyX Team"
+\pdf_subject "LyX's additional features documentation"
+\pdf_keywords "LyX, Documentation, Additional"
+\pdf_bookmarks true
+\pdf_bookmarksnumbered true
+\pdf_bookmarksopen false
+\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 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 1
+\math_indentation default
+\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
+Additional \SpecialChar LyX
+ Features
+\end_layout
+
+\begin_layout Subtitle
+Version 2.3.x
+\end_layout
+
+\begin_layout Author
+by the \SpecialChar LyX
+ Team
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+\noindent
+Principal maintainer of this file is
+\noun on
+ Richard Heck
+\noun default
+.
+ If you have comments or error corrections, please send them to the \SpecialChar LyX
+ Documentati
+on mailing list, 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+<lyx-docs at lists.lyx.org>
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset CommandInset toc
+LatexCommand tableofcontents
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Chapter
+\begin_inset CommandInset label
+LatexCommand label
+name "sec:Inserting-TeX-Code"
+
+\end_inset
+
+Inserting \SpecialChar TeX
+ Code into \SpecialChar LyX
+ Documents
+\end_layout
+
+\begin_layout Standard
+Anything you can do in \SpecialChar LaTeX
+ you can do in \SpecialChar LyX
+, for a very simple reason: You can
+ always insert \SpecialChar TeX
+ code into any \SpecialChar LyX
+ document.
+ \SpecialChar LyX
+ cannot, and will never be able to, display every possible \SpecialChar LaTeX
+ construct.
+ If ever you need to insert \SpecialChar LaTeX
+ commands into your \SpecialChar LyX
+ document, you can use the
+ 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+\SpecialChar TeX
+ Code
+\end_layout
+
+\end_inset
+
+ box, which you can insert into your document with 
+\begin_inset Flex Noun
+status collapsed
+
+\begin_layout Plain Layout
+Insert\SpecialChar menuseparator
+
+\family sans
+TeX
+\family default
+ Code
+\end_layout
+
+\end_inset
+
+ or the keyboard shortcut 
+\begin_inset Info
+type  "shortcut"
+arg   "ert-insert"
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+Here's an example of inserting \SpecialChar LaTeX
+ commands in a \SpecialChar LyX
+ document.
+ The code looks like this:
+\end_layout
+
+\begin_layout LyX-Code
+
+\backslash
+begin{tabular}{ll}
+\begin_inset Newline newline
+\end_inset
+
+
+\backslash
+begin{minipage}{5cm}
+\begin_inset Newline newline
+\end_inset
+
+This is an example of a minipage environment.
+ You 
+\begin_inset Newline newline
+\end_inset
+
+can put nearly everything in it, even (non-floating) 
+\begin_inset Newline newline
+\end_inset
+
+figures and tables.
+ 
+\begin_inset Newline newline
+\end_inset
+
+
+\backslash
+end{minipage}
+\begin_inset Newline newline
+\end_inset
+
+&
+\begin_inset Newline newline
+\end_inset
+
+
+\backslash
+begin{minipage}{5cm}
+\begin_inset Newline newline
+\end_inset
+
+
+\backslash
+begin{verbatim}
+\begin_inset Newline newline
+\end_inset
+
+
+\backslash
+begin{minipage}{5cm}
+\begin_inset Newline newline
+\end_inset
+
+This ...
+ 
+\begin_inset Newline newline
+\end_inset
+
+
+\backslash
+end{minipage}
+\begin_inset Newline newline
+\end_inset
+
+
+\backslash
+end{verbatim}
+\begin_inset Newline newline
+\end_inset
+
+
+\backslash
+end{minipage}
+\begin_inset Newline newline
+\end_inset
+
+
+\backslash
+end{tabular}
+\end_layout
+
+\begin_layout Section
+Cross-References Between Files
+\end_layout
+
+\begin_layout Standard
+\begin_inset Box Shadowbox
+position "t"
+hor_pos "c"
+has_inner_box 1
+inner_pos "t"
+use_parbox 0
+use_makebox 0
+width "100col%"
+special "none"
+height "1in"
+height_special "totalheight"
+thickness "0.4pt"
+separation "3pt"
+shadowsize "4pt"
+framecolor "black"
+backgroundcolor "none"
+status open
+
+\begin_layout Plain Layout
+This section is somewhat out of date.
+ Need to describe default master documents and how children are opened when
+ the master is.
+ [[FIXME]]
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_body
+\end_document
diff --git a/autotests/export/docbook/Additional_lyxcode.xml b/autotests/export/docbook/Additional_lyxcode.xml
new file mode 100644
index 0000000..b677971
--- /dev/null
+++ b/autotests/export/docbook/Additional_lyxcode.xml
@@ -0,0 +1,40 @@
+<?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 -->
+<book 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">
+<info>
+<title>Additional LyX Features</title>
+<subtitle>Version 2.3.x</subtitle>
+<author>
+<personname>by the LyX Team<footnote>
+<para>Principal maintainer of this file is<personname> Richard Heck</personname>. If you have comments or error corrections, please send them to the LyX Documentation mailing list, <code><lyx-docs at lists.lyx.org></code>.</para>
+</footnote></personname>
+</author>
+</info>
+<chapter xml:id="sec.Inserting-TeX-Code">
+<title>Inserting TeX Code into LyX Documents</title>
+<para>Anything you can do in LaTeX you can do in LyX, for a very simple reason: You can always insert TeX code into any LyX document. LyX cannot, and will never be able to, display every possible LaTeX construct. If ever you need to insert LaTeX commands into your LyX document, you can use the <code>TeX Code</code> box, which you can insert into your document with <personname>Insert&#x21D2;TeX Code</personname> or the keyboard shortcut <keycap>Ctrl+L</keycap>.</para>
+<para>Here's an example of inserting LaTeX commands in a LyX document. The code looks like this:</para>
+<programlisting language='lyx'>\begin{tabular}{ll}
+\begin{minipage}{5cm}
+This is an example of a minipage environment. You 
+can put nearly everything in it, even (non-floating) 
+figures and tables. 
+\end{minipage}
+&
+\begin{minipage}{5cm}
+\begin{verbatim}
+\begin{minipage}{5cm}
+This ... 
+\end{minipage}
+\end{verbatim}
+\end{minipage}
+\end{tabular}</programlisting>
+<section>
+<title>Cross-References Between Files</title>
+<sidebar role='shadowbox'>
+<para>This section is somewhat out of date. Need to describe default master documents and how children are opened when the master is. [[FIXME]]</para>
+</sidebar>
+</section>
+</chapter>
+</book>
\ No newline at end of file
diff --git a/lib/layouts/logicalmkup.module b/lib/layouts/logicalmkup.module
index bedf6dc..005a3c9 100644
--- a/lib/layouts/logicalmkup.module
+++ b/lib/layouts/logicalmkup.module
@@ -27,6 +27,8 @@ InsetLayout Flex:Noun
 	EndHTMLStyle
 	ResetsFont            true
 	CustomPars            false
+	DocBookTag            personname
+	DocBookTagType        inline
 End
 
 
@@ -42,6 +44,8 @@ InsetLayout Flex:Emph
 	HTMLTag               em
 	ResetsFont            true
 	CustomPars            false
+	DocBookTag            emphasis
+	DocBookTagType        inline
 End
 
 
@@ -60,6 +64,9 @@ InsetLayout Flex:Strong
 	HTMLTag               strong
 	ResetsFont            true
 	CustomPars            false
+	DocBookTag            personname
+	DocBookAttr           role='bold'
+	DocBookTagType        inline
 End
 
 
@@ -79,4 +86,6 @@ InsetLayout Flex:Code
 	ResetsFont            true
 	CustomPars            false
 	Spellcheck            false
+	DocBookTag            code
+	DocBookTagType        inline
 End
diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc
index ab15f77..fd2b75e 100644
--- a/lib/layouts/stdinsets.inc
+++ b/lib/layouts/stdinsets.inc
@@ -434,6 +434,8 @@ InsetLayout Box
 	  Size                Small
 	EndFont
 	MultiPar              true
+	DocBookWrapperTag     sidebar
+	DocBookTag            para
 End
 
 InsetLayout Box:Frameless
@@ -441,6 +443,9 @@ InsetLayout Box:Frameless
 	HTMLStyle
 		div.Frameless { margin: 1em; }
 	EndHTMLStyle
+	DocBookWrapperTag     sidebar
+	DocBookTag            para
+	DocBookWrapperAttr    role='frameless'
 End
 
 InsetLayout Box:Shaded
@@ -452,6 +457,9 @@ InsetLayout Box:Shaded
 			padding: 0.5ex;
 		}
 	EndHTMLStyle
+	DocBookWrapperTag     sidebar
+	DocBookTag            para
+	DocBookWrapperAttr    role='shaded'
 End
 
 InsetLayout Box:Boxed
@@ -462,6 +470,9 @@ InsetLayout Box:Boxed
 			padding: 0.5ex;
 		}
 	EndHTMLStyle
+	DocBookWrapperTag     sidebar
+	DocBookTag            para
+	DocBookWrapperAttr    role='boxed'
 End
 
 InsetLayout Box:Framed
@@ -472,6 +483,9 @@ InsetLayout Box:Framed
 			padding: 0.5ex;
 		}
 	EndHTMLStyle
+	DocBookWrapperTag     sidebar
+	DocBookTag            para
+	DocBookWrapperAttr    role='framed'
 End
 
 InsetLayout Box:ovalbox
@@ -482,6 +496,9 @@ InsetLayout Box:ovalbox
 			padding: 0.5ex;
 		}
 	EndHTMLStyle
+	DocBookWrapperTag     sidebar
+	DocBookTag            para
+	DocBookWrapperAttr    role='ovalbox'
 End
 
 InsetLayout Box:Ovalbox
@@ -492,6 +509,9 @@ InsetLayout Box:Ovalbox
 			padding: 0.5ex;
 		}
 	EndHTMLStyle
+	DocBookWrapperTag     sidebar
+	DocBookTag            para
+	DocBookWrapperAttr    role='ovalbox-var'
 End
 
 InsetLayout Box:Shadowbox
@@ -499,6 +519,9 @@ InsetLayout Box:Shadowbox
 	HTMLStyle
 		div.Shadowbox { border: solid gray medium; border-bottom: solid black 1ex; border-right: solid black 1ex; padding: 0.5ex; }
 	EndHTMLStyle
+	DocBookWrapperTag     sidebar
+	DocBookTag            para
+	DocBookWrapperAttr    role='shadowbox'
 End
 
 InsetLayout Box:Doublebox
@@ -509,6 +532,9 @@ InsetLayout Box:Doublebox
 			padding: 0.5ex;
 		}
 	EndHTMLStyle
+	DocBookWrapperTag     sidebar
+	DocBookTag            para
+	DocBookWrapperAttr    role='doublebox'
 End
 
 InsetLayout Float
@@ -609,6 +635,8 @@ InsetLayout Info:menu
 	HTMLStyle
 		span.menu { font-family: sans-serif; }
 	EndHTMLStyle
+	DocBookTag            guimenu
+	DocBookTagType        inline
 End
 
 InsetLayout Info:shortcut
@@ -626,6 +654,10 @@ InsetLayout Info:shortcut
 	HTMLStyle
 		span.shortcut { font-family: sans-serif; }
 	EndHTMLStyle
+	DocBookWrapperTag     keycombo
+	DocBookWrapperTagType inline
+	DocBookTag            keycap
+	DocBookTagType        inline
 End
 
 InsetLayout Info:shortcuts
@@ -643,6 +675,10 @@ InsetLayout Info:shortcuts
 	HTMLStyle
 		span.shortcuts { font-family: sans-serif; }
 	EndHTMLStyle
+	DocBookWrapperTag     keycombo
+	DocBookWrapperTagType inline
+	DocBookTag            keycap
+	DocBookTagType        inline
 End
 
 InsetLayout Caption:Standard
diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp
index c61efe6..db76f53 100644
--- a/src/insets/InsetBox.cpp
+++ b/src/insets/InsetBox.cpp
@@ -717,7 +717,25 @@ int InsetBox::plaintext(odocstringstream & os,
 
 void InsetBox::docbook(XMLStream & xs, OutputParams const & runparams) const
 {
+	if (!getLayout().docbookwrappertag().empty()) {
+		if (!xs.isLastTagCR())
+			xs << xml::CR();
+
+		xs << xml::StartTag(getLayout().docbookwrappertag(), getLayout().docbookwrapperattr());
+		xs << xml::CR();
+	} else {
+		LYXERR0("Assertion failed: box layout " + getLayout().name() + " missing DocBookWrapperTag.");
+	}
+
 	InsetText::docbook(xs, runparams);
+
+	if (!getLayout().docbookwrappertag().empty()) {
+		if (!xs.isLastTagCR())
+			xs << xml::CR();
+
+		xs << xml::EndTag(getLayout().docbookwrappertag());
+		xs << xml::CR();
+	}
 }
 
 
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index ce0d25a..d758a1c 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -110,7 +110,11 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
 		IL_HTMLSTYLE,
 		IL_HTMLPREAMBLE,
 		IL_DOCBOOKTAG,
+		IL_DOCBOOKTAGTYPE,
 		IL_DOCBOOKATTR,
+		IL_DOCBOOKWRAPPERTAG,
+		IL_DOCBOOKWRAPPERTAGTYPE,
+		IL_DOCBOOKWRAPPERATTR,
 		IL_INTOC,
 		IL_ISTOCCAPTION,
 		IL_LABELFONT,
@@ -157,6 +161,10 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
 		{ "display", IL_DISPLAY },
 		{ "docbookattr", IL_DOCBOOKATTR },
 		{ "docbooktag", IL_DOCBOOKTAG },
+		{ "docbooktagtype", IL_DOCBOOKTAGTYPE },
+		{ "docbookwrapperattr", IL_DOCBOOKWRAPPERATTR },
+		{ "docbookwrappertag", IL_DOCBOOKWRAPPERTAG },
+		{ "docbookwrappertagtype", IL_DOCBOOKWRAPPERTAGTYPE },
 		{ "editexternal", IL_EDITEXTERNAL },
 		{ "end", IL_END },
 		{ "fixedwidthpreambleencoding", IL_FIXEDWIDTH_PREAMBLE_ENCODING },
@@ -500,9 +508,21 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
 		case IL_DOCBOOKTAG:
 			lex >> docbooktag_;
 			break;
+		case IL_DOCBOOKTAGTYPE:
+			lex >> docbooktagtype_;
+			break;
 		case IL_DOCBOOKATTR:
 			lex >> docbookattr_;
 			break;
+		case IL_DOCBOOKWRAPPERTAG:
+			lex >> docbookwrappertag_;
+			break;
+		case IL_DOCBOOKWRAPPERTAGTYPE:
+			lex >> docbookwrappertagtype_;
+			break;
+		case IL_DOCBOOKWRAPPERATTR:
+			lex >> docbookwrapperattr_;
+			break;
 		case IL_REQUIRES: {
 			lex.eatLine();
 			vector<string> const req
diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index 00e3ba6..f11071f 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -150,8 +150,16 @@ public:
 	///
 	std::string docbooktag() const { return docbooktag_; }
 	///
+	std::string docbooktagtype() const { return docbooktagtype_; }
+	///
 	std::string docbookattr() const { return docbookattr_; }
 	///
+	std::string docbookwrappertag() const { return docbookwrappertag_; }
+	///
+	std::string docbookwrappertagtype() const { return docbookwrappertagtype_; }
+	///
+	std::string docbookwrapperattr() const { return docbookwrapperattr_; }
+	///
 	std::set<std::string> required() const { return required_; }
 	///
 	bool isMultiPar() const { return multipar_; }
@@ -281,8 +289,16 @@ private:
 	///
 	std::string docbooktag_;
 	///
+	std::string docbooktagtype_;
+	///
 	std::string docbookattr_;
 	///
+	std::string docbookwrappertag_;
+	///
+	std::string docbookwrappertagtype_;
+	///
+	std::string docbookwrapperattr_;
+	///
 	std::set<std::string> required_;
 	///
 	bool multipar_;
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index cf3873b..1f17351 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -493,6 +493,10 @@ void makeParagraph(
 		// Listings should not get into their own paragraph.
 		if (!special_case && firstInset->lyxCode() == lyx::LISTINGS_CODE)
 			special_case = true;
+
+		// Boxes cannot get into their own paragraph.
+		if (!special_case && firstInset->lyxCode() == lyx::BOX_CODE)
+			special_case = true;
 	}
 
 	bool const open_par = runparams.docbook_make_pars

commit 3dcdc451f33116aae32366d569032905f1cbbcc5
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 01:24:28 2020 +0200

    DocBook: implement LyX-Code.
    
    This is quite ugly.

diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout
index f6d17c3..4438482 100644
--- a/lib/layouts/beamer.layout
+++ b/lib/layouts/beamer.layout
@@ -1408,6 +1408,9 @@ Style LyX-Code
   Font
     Family         Typewriter
   EndFont
+  DocBookTag            programlisting
+  DocBookTagType        paragraph
+  DocBookAttr			language='lyx'
 End
  
 Style NoteItem
diff --git a/lib/layouts/egs.layout b/lib/layouts/egs.layout
index 6ee01ed..0bd4543 100644
--- a/lib/layouts/egs.layout
+++ b/lib/layouts/egs.layout
@@ -734,6 +734,9 @@ Style LyX-Code
 	Font
 	  Family              Typewriter
 	EndFont
+	DocBookTag            programlisting
+    DocBookTagType        paragraph
+	DocBookAttr			  language='lyx'
 End
 
 
diff --git a/lib/layouts/lyxmacros.inc b/lib/layouts/lyxmacros.inc
index 1696ffd..4cf5cf6 100644
--- a/lib/layouts/lyxmacros.inc
+++ b/lib/layouts/lyxmacros.inc
@@ -38,6 +38,9 @@ Style LyX-Code
 	Font
 	  Family              Typewriter
 	EndFont
+	DocBookTag            programlisting
+    DocBookTagType        paragraph
+	DocBookAttr			  language='lyx'
 End
 
 
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index ce631e9..cf3873b 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -534,8 +534,19 @@ void makeEnvironment(Text const &text,
                      OutputParams const &runparams,
                      ParagraphList::const_iterator const & par)
 {
-	// TODO: simplify me!
 	auto const end = text.paragraphs().end();
+	auto nextpar = par;
+	++nextpar;
+
+	// Special cases for listing-like environments provided in layouts. This is quite ad-hoc, but provides a useful
+	// default. This should not be used by too many environments (only LyX-Code right now).
+	// This would be much simpler if LyX-Code was implemented as InsetListings...
+	bool mimicListing = false;
+	bool ignoreFonts = false;
+	if (par->layout().docbooktag() == "programlisting") {
+		mimicListing = true;
+		ignoreFonts = true;
+	}
 
 	// Output the opening tag for this environment, but only if it has not been previously opened (condition
 	// implemented in openParTag).
@@ -547,65 +558,25 @@ void makeEnvironment(Text const &text,
 	if (style.latextype == LATEX_COMMAND) {
 		// Nothing to do (otherwise, infinite loops).
 	} else if (style.latextype == LATEX_ENVIRONMENT) {
-		// Open a wrapper tag if needed.
-		if (style.docbookitemwrappertag() != "NONE")
-			openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype());
-
-		// Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first
-		// character after the label.
-		pos_type sep = 0;
-		if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") {
-			// At least one condition must be met:
-			//  - this environment is not a list
-			//  - if this is a list, the label must not be manual (i.e. it must be taken from the layout)
-			if (style.latextype != LATEX_LIST_ENVIRONMENT || style.labeltype != LABEL_MANUAL) {
-				// Usual cases: maybe there is something specified at the layout level. Highly unlikely, though.
-				docstring const lbl = par->params().labelString();
+		// Generate the paragraph, if need be.
+		auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), 0, false, ignoreFonts);
 
-				if (!lbl.empty()) {
-					openLabelTag(xs, style);
-					xs << lbl;
-					closeLabelTag(xs, style);
-				}
-			} else {
-				// Only variablelist gets here (or similar items defined as an extension in the layout).
-				openLabelTag(xs, style);
-				sep = par->firstWordDocBook(xs, runparams);
-				closeLabelTag(xs, style);
-			}
-		}
-
-		// Maybe the item is completely empty, i.e. if the first word ends at the end of the current paragraph
-		// AND if the next paragraph doesn't have the same depth (if there is such a paragraph).
-		// Common case: there is only the first word on the line, but there is a nested list instead
-		// of more text.
-		bool emptyItem = false;
-		if (sep == par->size()) { // If the separator is already at the end of this paragraph...
-			auto next_par = par;
-			++next_par;
-			if (next_par == text.paragraphs().end()) // There is no next paragraph.
-				emptyItem = true;
-			else // There is a next paragraph: check depth.
-				emptyItem = par->params().depth() >= next_par->params().depth();
-		}
-
-		if (emptyItem) {
-			// Avoid having an empty item, this is not valid DocBook. A single character is enough to force
-			// generation of a full <para>.
-			// TODO: this always worked only by magic...
-			xs << ' ';
-		} else {
-			// Generate the rest of the paragraph, if need be. Open as many inner tags as necessary.
-			auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), sep);
+		if (mimicListing) {
 			auto p = pars.begin();
-			while (true) {
+			while (p != pars.end()) {
+				openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype());
 				xs << XMLStream::ESCAPE_NONE << *p;
+				closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype());
 				++p;
-				if (p != pars.end()) {
-					closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype());
-					openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype());
-				} else
-					break;
+
+				if (p != pars.end())
+					xs << xml::CR();
+			}
+		} else {
+			for (auto const & p : pars) {
+				openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype());
+				xs << XMLStream::ESCAPE_NONE << p;
+				closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype());
 			}
 		}
 	} else {
@@ -613,8 +584,6 @@ void makeEnvironment(Text const &text,
 	}
 
 	// Close the environment.
-	auto nextpar = par;
-	++nextpar;
 	closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); // TODO: switch in layout for par/block?
 }
 

commit b9ad1ef6edd964b1c858f4433aeaed238f8a3eca
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 00:50:37 2020 +0200

    DocBook: <person> is not valid per se, rather use <personname>.
    
    The cleanest solution would still be <person><personname>, but this ought to be enough. Otherwise, that would imply having two tags for some fonts...

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index c80988b..ce631e9 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -49,7 +49,7 @@ std::string fontToDocBookTag(xml::FontTypes type)
 	case xml::FontTypes::FT_BOLD:
 		return "emphasis";
 	case xml::FontTypes::FT_NOUN:
-		return "person";
+		return "personname";
 	case xml::FontTypes::FT_UBAR:
 	case xml::FontTypes::FT_WAVE:
 	case xml::FontTypes::FT_DBAR:

commit 83b5416518c0bbb39919f09a22a2460a738be586
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 00:46:49 2020 +0200

    DocBook: subfigures example is fixed.
    
    Probably thanks to the magic of the previous commits.

diff --git a/autotests/export/docbook/subfigures.xml b/autotests/export/docbook/subfigures.xml
index 4a7c122..622edb8 100644
--- a/autotests/export/docbook/subfigures.xml
+++ b/autotests/export/docbook/subfigures.xml
@@ -1,7 +1,7 @@
 <?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>Formalgroup with two images: </para>
 <formalgroup>
@@ -10,7 +10,7 @@
 <title>Subfigure a.</title>
 <mediaobject>
 <imageobject>
-<imagedata fileref="C:/Users/Thibaut/Documents/GitHub/Apprentissage_automatique/01_manus_lyx/lyx-logo.png"  />
+<imagedata fileref="D:/LyX/lyx-unstable/autotests/export/docbook/lyx-logo.png"  />
 </imageobject>
 </mediaobject>
 </figure>
@@ -18,7 +18,7 @@
 <title>Subfigure b.</title>
 <mediaobject>
 <imageobject>
-<imagedata fileref="C:/Users/Thibaut/Documents/GitHub/Apprentissage_automatique/01_manus_lyx/lyx-logo.png"  />
+<imagedata fileref="D:/LyX/lyx-unstable/autotests/export/docbook/lyx-logo.png"  />
 </imageobject>
 </mediaobject>
 </figure>
@@ -29,7 +29,7 @@
 <title>Subfigure a.</title>
 <mediaobject>
 <imageobject>
-<imagedata fileref="C:/Users/Thibaut/Documents/GitHub/Apprentissage_automatique/01_manus_lyx/lyx-logo.png"  />
+<imagedata fileref="D:/LyX/lyx-unstable/autotests/export/docbook/lyx-logo.png"  />
 </imageobject>
 </mediaobject>
 </figure>
@@ -37,11 +37,12 @@
 <title>Subfigure b.</title>
 <mediaobject>
 <imageobject>
-<imagedata fileref="C:/Users/Thibaut/Documents/GitHub/Apprentissage_automatique/01_manus_lyx/lyx-logo.png"  />
+<imagedata fileref="D:/LyX/lyx-unstable/autotests/export/docbook/lyx-logo.png"  />
 </imageobject>
 </mediaobject>
 </figure>
 </formalgroup>
+
 <para>Formalgroup with two tables: </para>
 <formalgroup>
 <title>Formalgroup, tables above.</title>
@@ -51,10 +52,12 @@
 <tr>
 <td align='center' valign='top'>a</td>
 <td align='center' valign='top'>b</td>
-</tr><tr>
+</tr>
+<tr>
 <td align='center' valign='top'>c</td>
 <td align='center' valign='top'>d</td>
-</tr></tbody>
+</tr>
+</tbody>
 </table>
 <table>
 <caption>Subtable b.</caption>
@@ -62,7 +65,8 @@
 <tr>
 <td align='center' valign='top'>a</td>
 <td align='center' valign='top'>b</td>
-</tr><tr>
+</tr>
+<tr>
 <td align='center' valign='top'>c</td>
 <td align='center' valign='top'>d</td>
 </tr>
@@ -77,10 +81,12 @@
 <tr>
 <td align='center' valign='top'>a</td>
 <td align='center' valign='top'>b</td>
-</tr><tr>
+</tr>
+<tr>
 <td align='center' valign='top'>c</td>
 <td align='center' valign='top'>d</td>
-</tr></tbody>
+</tr>
+</tbody>
 </table>
 <table>
 <caption>Subtable b.</caption>
@@ -88,11 +94,12 @@
 <tr>
 <td align='center' valign='top'>a</td>
 <td align='center' valign='top'>b</td>
-</tr><tr>
+</tr>
+<tr>
 <td align='center' valign='top'>c</td>
 <td align='center' valign='top'>d</td>
-</tr></tbody>
+</tr>
+</tbody>
 </table>
 </formalgroup>
-
-</article>
+</article>
\ No newline at end of file

commit 67988d233e297bbc70375572bd7b0a5e1d26a1d2
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 00:45:19 2020 +0200

    DocBook: new-line behaviour in bibliographies.

diff --git a/autotests/export/docbook/Tufte_Book.xml b/autotests/export/docbook/Tufte_Book.xml
index 4968e25..3289cfd 100644
--- a/autotests/export/docbook/Tufte_Book.xml
+++ b/autotests/export/docbook/Tufte_Book.xml
@@ -34,12 +34,15 @@ Working with Text
 <bibliography>
 <title>References</title>
 <biblioentry xml:id="Bringhurst2005">
-<title>The Elements of Typographic Style</title><edition>3.1</edition><bibliomisc role="type">book</bibliomisc>
+<title>The Elements of Typographic Style</title>
+<edition>3.1</edition>
+<bibliomisc role="type">book</bibliomisc>
 <publisher>
 <publishername>Hartley & Marks</publishername>
 </publisher>
 <pubdate>2005</pubdate>
-<authorgroup><author>
+<authorgroup>
+<author>
 <personname>
 <firstname>Robert</firstname>
 <surname>Bringhurst</surname>
diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index 7005519..6d2af6c 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -1700,6 +1700,8 @@ docstring authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream
 
 	// Output the list of authors.
 	xs << xml::StartTag("authorgroup");
+	xs << xml::CR();
+
 	auto it = authors.cbegin();
 	auto en = authors.cend();
 	for (size_t i = 0; it != en; ++it, ++i) {
diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index 05fd23d..bee485e 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1200,6 +1200,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const
 					xs << xml::StartTag(toDocBookTag[match[1]]);
 					xs << from_utf8(match[2].str());
 					xs << xml::EndTag(toDocBookTag[match[1]]);
+					xs << xml::CR();
 				}
 			} else {
 				LYXERR0("The BibTeX field " << match[1].str() << " is unknown.");

commit b76a8fb57a990819579c66b8957727aec6998dfc
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 00:43:02 2020 +0200

    DocBook: support Full Width from Tufte Book.

diff --git a/autotests/export/docbook/Tufte_Book.xml b/autotests/export/docbook/Tufte_Book.xml
index 3fb7f24..4968e25 100644
--- a/autotests/export/docbook/Tufte_Book.xml
+++ b/autotests/export/docbook/Tufte_Book.xml
@@ -3,26 +3,32 @@
   See http://www.lyx.org/ for more information -->
 <book 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">
 <info>
-
 <title>Tufte Examples</title>
+<author>
+<personname>Fake Author</personname>
+</author>
 </info>
 <chapter>
-<title>The Features of the Tufte-book Class</title>
+<title>
+The Features of the Tufte-book Class
+</title>
 <para>In this document, it was endeavored to show some of the features of the <emphasis role='sans'>Tufte-book</emphasis> class. In the first chapter, their use is outlined. In the second chapter, their use through a handout that was created in a calculus class is demonstrated.</para>
 <section>
-<title>Working with Text</title>
-<para>One of the most prominent and distinctive features of this style is the extensive use of sidenotes. There is a wide margin to provide ample room for sidenotes and small figures. Any footnotes will automatically be converted to sidenotes.<footnote><para>This is a sidenote that was entered using a <code>footnote</code>.</para>
-</footnote> Alternatively, you can also use the <code>Sidenote</code> inset directly; you'll find it in the <emphasis role='sans'>Insert&#x21D2;Custom Insets</emphasis> menu.This is a sidenote that was entered using a <code>sidenote</code>.</para>
+<title>
+Working with Text
+</title>
+<para>One of the most prominent and distinctive features of this style is the extensive use of sidenotes. There is a wide margin to provide ample room for sidenotes and small figures. Any footnotes will automatically be converted to sidenotes.<footnote>
+<para>This is a sidenote that was entered using a <code>footnote</code>.</para>
+</footnote> Alternatively, you can also use the <code>Sidenote</code> inset directly; you'll find it in the <emphasis role='sans'>Insert&#x21D2;Custom Insets</emphasis> menu.This is a sidenote that was entered using a sidenote.</para>
 <para>If you like to place ancillary information in the margin without the sidenote mark (the superscript number), you can use the <code>Marginnote</code> inset. This is Tufte's margin note. Notice that there isn't a number preceding the note, and there is no number in the main text where this note was written. The normal margin note will work as well, but it will look rather odd.<sidebar role="margin">
-<?dbfo float-type="margin.note"?><sidebar role="margin">This is a normal margin note. Don't use it.</sidebar></sidebar></para>
-<para>Another useful innovation is Tufte's <code>NewThought</code> character style (<emphasis role='sans'>Edit&#x21D2;TextStyle&#x21D2;NewThought</emphasis>). It introduces new thoughts by means of small caps, as demonstrated in this paragraph. </para>
+<?dbfo float-type="margin.note"?>
+<para>This is a normal margin note. Don't use it.</para></sidebar></para>
+<para><emphasis role='newthought'>Another useful</emphasis> innovation is Tufte's <code>NewThought</code> character style (<emphasis role='sans'>Edit&#x21D2;TextStyle&#x21D2;NewThought</emphasis>). It introduces new thoughts by means of small caps, as demonstrated in this paragraph. </para>
 <para>The Tufte document classes include two new character styles and some improvements on existing commands for letterspacing.</para>
-<para>When setting strings of <emphasis role='allcaps'>ALL CAPS</emphasis> or small caps, the letterspacing—that is, the spacing between the letters—should be increased slightly.<biblioref endterm="Bringhurst2005" /> The <emphasis>AllCaps</emphasis> character style (<emphasis role='sans'>Edit&#x21D2;TextStyle&#x21D2;AllCaps</emphasis>) has proper letterspacing for strings of <emphasis role='allcaps'>FULL CAPITAL LETTERS</emphasis>, and the <emphasis>SmallCaps</emphasis> character style (<emphasis role='sans'>Edit&#x21D2;TextStyle&#x21D2;SmallCaps</emphasis>) has letterspacing for small capital letters. These commands will also automatically convert the case of the text to upper- or lowercase, respectively.</para>
+<para>When setting strings of <emphasis role='allcaps'>ALL CAPS</emphasis> or <emphasis role='smallcaps'>small caps</emphasis>, the letterspacing—that is, the spacing between the letters—should be increased slightly.<biblioref endterm="Bringhurst2005" /> The <emphasis>AllCaps</emphasis> character style (<emphasis role='sans'>Edit&#x21D2;TextStyle&#x21D2;AllCaps</emphasis>) has proper letterspacing for strings of <emphasis role='allcaps'>FULL CAPITAL LETTERS</emphasis>, and the <emphasis>SmallCaps</emphasis> character style (<emphasis role='sans'>Edit&#x21D2;TextStyle&#x21D2;SmallCaps</emphasis>) has letterspacing for <emphasis role='smallcaps'>small capital letters</emphasis>. These commands will also automatically convert the case of the text to upper- or lowercase, respectively.</para>
 <para>The normal <emphasis>Small Caps</emphasis> shape has also been redefined to include letterspacing. Its case is left as is, however. This allows one to use both uppercase and lowercase letters: <emphasis role='smallcaps'>The Initial Letters Of The Words In This Sentence Are Capitalized.</emphasis></para>
 <para>Finally, the<emphasis> Full Width</emphasis> paragraph environment provides a paragraph layout that stretches across the main text block and the sidenotes area:</para>
-<Full Width>
-Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.
-</Full Width>
+<para role='fullwidth'>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.</para>
 </section>
 </chapter>
 <bibliography>
diff --git a/lib/layouts/tufte-book.layout b/lib/layouts/tufte-book.layout
index 2b88ca3..e469996 100644
--- a/lib/layouts/tufte-book.layout
+++ b/lib/layouts/tufte-book.layout
@@ -243,6 +243,8 @@ Style Full_Width
 	Align			Block
 	AlignPossible	Block, Left, Right, Center
 	LabelType		No_Label
+	DocBookTag      para
+	DocBookAttr     role='fullwidth'
 End
 
 # this steps the counters

commit 260b2909dd0f77fda4cfbf76a3fb0748eccffc6a
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 00:42:32 2020 +0200

    DocBook: fix margin notes.
    
    They were nested twice in <sidebar>. Also fixes a new line issue.

diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc
index 04c464a..ab15f77 100644
--- a/lib/layouts/stdinsets.inc
+++ b/lib/layouts/stdinsets.inc
@@ -44,8 +44,7 @@ InsetLayout Marginal
 	EndHTMLStyle
 	AddToToc              marginalnote
 	IsTocCaption          true
-	DocBookTag            sidebar
-	DocBookAttr           role="margin"
+	DocBookTag            para
 End
 
 InsetLayout Foot
diff --git a/src/insets/InsetMarginal.cpp b/src/insets/InsetMarginal.cpp
index 5d2fb90..3a5296d 100644
--- a/src/insets/InsetMarginal.cpp
+++ b/src/insets/InsetMarginal.cpp
@@ -49,6 +49,7 @@ void InsetMarginal::docbook(XMLStream & xs, OutputParams const & runparams) cons
 	xs << xml::StartTag("sidebar", "role=\"margin\"");
 	xs << xml::CR();
 	xs << XMLStream::ESCAPE_NONE << "<?dbfo float-type=\"margin.note\"?>";
+	xs << xml::CR();
 	InsetText::docbook(xs, runparams);
 	xs << xml::EndTag("sidebar");
 }

commit 79601dbbe9d0607abb0adeeb39cc5ebaf2d26902
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 00:21:12 2020 +0200

    DocBook: new lines around formulae.

diff --git a/autotests/export/docbook/mathml_ns_entities.xml b/autotests/export/docbook/mathml_ns_entities.xml
index 2ee7f39..0c1509e 100644
--- a/autotests/export/docbook/mathml_ns_entities.xml
+++ b/autotests/export/docbook/mathml_ns_entities.xml
@@ -1,21 +1,24 @@
 <?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 formula: 
- <informalequation>
-  <m:math>
-  <m:alt role='tex'>\Vert,\vert</m:alt>
+<informalequation>
+<alt role='tex'>\Vert,\vert</alt>
+ <m:math>
+ 
  <m:mrow>
   <m:mrow><m:mi>&#x2225;</m:mi><m:mo>,</m:mo><m:mi>&#x007C;</m:mi>
   </m:mrow>
  </m:mrow>
-  </m:math>
- </informalequation>A second formula: 
- <informalequation>
-  <m:math>
-  <m:alt role='tex'>\left\Vert \mathbf{a^{T}\,x}\right\Vert _{2}\leq x_{0}</m:alt>
+ </m:math>
+</informalequation>
+A second formula: 
+<informalequation>
+<alt role='tex'>\left\Vert \mathbf{a^{T}\,x}\right\Vert _{2}\leq x_{0}</alt>
+ <m:math>
+ 
  <m:mrow>
   <m:mrow>
    <m:msub>
@@ -45,7 +48,7 @@
    </m:msub>
   </m:mrow>
  </m:mrow>
-  </m:math>
- </informalequation></para>
-
-</article>
+ </m:math>
+</informalequation>
+</para>
+</article>
\ No newline at end of file
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index af30e8e..e7326b6 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2418,13 +2418,11 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
 {
 	// Choose the tag around the MathML equation.
 	docstring name;
+	bool doCR = false;
 	if (getType() == hullSimple)
 		name = from_ascii("inlineequation");
 	else {
-		// This is a block equation, always have <informalequation> on its own line.
-		if (!xs.isLastTagCR())
-			xs << xml::CR();
-
+		doCR = true; // This is a block equation, always have <informalequation> on its own line.
 		name = from_ascii("informalequation");
 	}
 
@@ -2439,6 +2437,10 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
 		}
 	}
 
+	if (doCR)
+		if (!xs.isLastTagCR())
+			xs << xml::CR();
+
 	xs << xml::StartTag(name, attr);
 	xs << xml::CR();
 
@@ -2485,6 +2487,8 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
 	xs << XMLStream::ESCAPE_NONE << osmath.str();
 	xs << xml::CR();
 	xs << xml::EndTag(name);
+	if (doCR)
+		xs << xml::CR();
 }
 
 

commit a0043adead3d9471230a81b01242613020e37848
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 31 00:18:35 2020 +0200

    DocBook: avoid generating fonts for "special cases" like equations.

diff --git a/autotests/export/docbook/lists.xml b/autotests/export/docbook/lists.xml
index 6812230..ce2d970 100644
--- a/autotests/export/docbook/lists.xml
+++ b/autotests/export/docbook/lists.xml
@@ -125,7 +125,7 @@
 <varlistentry>
 <term>LyX:</term>
 <listitem>
-
+<para />
 <variablelist>
 <varlistentry>
 <term>lyx16</term>
diff --git a/autotests/export/docbook/math_in_font.xml b/autotests/export/docbook/math_in_font.xml
index 0758a2e..45bb544 100644
--- a/autotests/export/docbook/math_in_font.xml
+++ b/autotests/export/docbook/math_in_font.xml
@@ -4,7 +4,8 @@
 <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>LyX</title>
 <para>Some text before.</para>
-<informalequation><alt role='tex'>\cfrac[l]{A}{B+C}\,,\,\cfrac{A}{B+C}\,,\,\cfrac[r]{A}{B+C}</alt>
+<informalequation>
+<alt role='tex'>\cfrac[l]{A}{B+C}\,,\,\cfrac{A}{B+C}\,,\,\cfrac[r]{A}{B+C}</alt>
  <m:math>
  
  <m:mrow>
@@ -35,6 +36,7 @@
    </m:mfrac>
   </m:mrow>
  </m:mrow>
- </m:math></informalequation><para>Some text after.</para>
-
+ </m:math>
+</informalequation>
+<para>Some text after.</para>
 </article>
\ No newline at end of file
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index b88c381..9dea24b 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3333,7 +3333,8 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
                                                       OutputParams const & runparams,
                                                       Font const & outerfont,
                                                       pos_type initial,
-                                                      bool is_last_par) const
+                                                      bool is_last_par,
+                                                      bool ignore_fonts) const
 {
 	// Track whether we have opened these tags
 	DocBookFontState fs;
@@ -3362,33 +3363,37 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
 		// If this is an InsetNewline, generate a new paragraph. Also reset the fonts, so that tags are closed in
 		// this paragraph.
 		if (getInset(i) != nullptr && getInset(i)->lyxCode() == NEWLINE_CODE) {
-			xs->closeFontTags();
+			if (!ignore_fonts)
+				xs->closeFontTags();
 			generatedParagraphs.push_back(os.str());
 			os = odocstringstream();
 			delete xs;
 			xs = new XMLStream(os);
-			font_old = outerfont.fontInfo();
+			if (!ignore_fonts)
+				font_old = outerfont.fontInfo();
 		}
 
-		// Determine which tags should be opened or closed.
+		// Determine which tags should be opened or closed regarding fonts.
 		Font const font = getFont(buf.masterBuffer()->params(), i, outerfont);
-		tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(font_old, font, default_family, fs);
+		if (!ignore_fonts) {
+			tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(font_old, font, default_family, fs);
 
-		// FIXME XHTML
-		// Other such tags? What about the other text ranges?
+			// FIXME XHTML
+			// Other such tags? What about the other text ranges?
 
-		vector<xml::EndFontTag>::const_iterator cit = tagsToClose.begin();
-		vector<xml::EndFontTag>::const_iterator cen = tagsToClose.end();
-		for (; cit != cen; ++cit)
-			*xs << *cit;
+			vector<xml::EndFontTag>::const_iterator cit = tagsToClose.begin();
+			vector<xml::EndFontTag>::const_iterator cen = tagsToClose.end();
+			for (; cit != cen; ++cit)
+				*xs << *cit;
 
-		vector<xml::FontTag>::const_iterator sit = tagsToOpen.begin();
-		vector<xml::FontTag>::const_iterator sen = tagsToOpen.end();
-		for (; sit != sen; ++sit)
-			*xs << *sit;
+			vector<xml::FontTag>::const_iterator sit = tagsToOpen.begin();
+			vector<xml::FontTag>::const_iterator sen = tagsToOpen.end();
+			for (; sit != sen; ++sit)
+				*xs << *sit;
 
-		tagsToClose.clear();
-		tagsToOpen.clear();
+			tagsToClose.clear();
+			tagsToOpen.clear();
+		}
 
 		if (Inset const * inset = getInset(i)) {
 			if (!runparams.for_toc || inset->isInToc()) {
@@ -3409,7 +3414,8 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
 	// FIXME, this code is just imported from XHTML
 	// I'm worried about what happens if a branch, say, is itself
 	// wrapped in some font stuff. I think that will not work.
-	xs->closeFontTags();
+	if (!ignore_fonts)
+		xs->closeFontTags();
 
 	// In listings, new lines are very important. Avoid generating one for the last line.
 	if (runparams.docbook_in_listing && !is_last_par)
diff --git a/src/Paragraph.h b/src/Paragraph.h
index 96c19c0..597a10b 100644
--- a/src/Paragraph.h
+++ b/src/Paragraph.h
@@ -214,7 +214,8 @@ public:
 							                   OutputParams const & runparams,
 							                   Font const & outerfont,
 							                   pos_type initial = 0,
-							                   bool is_last_par = false) const;
+							                   bool is_last_par = false,
+							                   bool ignore_fonts = false) const;
 
 	/// \return any material that has had to be deferred until after the
 	/// paragraph has closed.
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 808b4cf..c80988b 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -513,7 +513,7 @@ void makeParagraph(
 	// Open and close tags around each contained paragraph.
 	auto nextpar = par;
 	++nextpar;
-	auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end);
+	auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end, special_case);
 	for (auto & parXML : pars) {
 		if (!std::all_of(parXML.begin(), parXML.end(), ::isspace)) {
 			if (open_par)

commit 22b4d43f6ae040876a905eb431d500534c70179c
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 23:56:16 2020 +0200

    DocBook: fix line issues around programlisting.

diff --git a/autotests/export/docbook/listings.xml b/autotests/export/docbook/listings.xml
index e65de60..1ed2694 100644
--- a/autotests/export/docbook/listings.xml
+++ b/autotests/export/docbook/listings.xml
@@ -5,6 +5,5 @@
 <title>Test document</title>
 <para>This is a programlisting: </para>
 <programlisting>First line of programlisting
-Second line of programlisting
-</programlisting>
+Second line of programlisting</programlisting>
 </article>
\ No newline at end of file
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index b4e4bc3..b88c381 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3332,7 +3332,8 @@ std::tuple<vector<xml::FontTag>, vector<xml::EndFontTag>> computeDocBookFontSwit
 std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
                                                       OutputParams const & runparams,
                                                       Font const & outerfont,
-                                                      pos_type initial) const
+                                                      pos_type initial,
+                                                      bool is_last_par) const
 {
 	// Track whether we have opened these tags
 	DocBookFontState fs;
@@ -3409,7 +3410,9 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
 	// I'm worried about what happens if a branch, say, is itself
 	// wrapped in some font stuff. I think that will not work.
 	xs->closeFontTags();
-	if (runparams.docbook_in_listing)
+
+	// In listings, new lines are very important. Avoid generating one for the last line.
+	if (runparams.docbook_in_listing && !is_last_par)
 		*xs << xml::CR();
 
 	// Finalise the last (and most likely only) paragraph.
diff --git a/src/Paragraph.h b/src/Paragraph.h
index ee31403..96c19c0 100644
--- a/src/Paragraph.h
+++ b/src/Paragraph.h
@@ -213,7 +213,8 @@ public:
 	std::vector<docstring> simpleDocBookOnePar(Buffer const & buf,
 							                   OutputParams const & runparams,
 							                   Font const & outerfont,
-							                   pos_type initial = 0) const;
+							                   pos_type initial = 0,
+							                   bool is_last_par = false) const;
 
 	/// \return any material that has had to be deferred until after the
 	/// paragraph has closed.
diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp
index 848e4ae..93daab4 100644
--- a/src/insets/InsetListings.cpp
+++ b/src/insets/InsetListings.cpp
@@ -485,6 +485,9 @@ void InsetListings::docbook(XMLStream & xs, OutputParams const & rp) const
 {
 	InsetLayout const & il = getLayout();
 
+	if (!xs.isLastTagCR())
+		xs << xml::CR();
+
 	// Forge the attributes.
 	string attrs;
 	if (!il.docbookattr().empty())
@@ -517,6 +520,7 @@ void InsetListings::docbook(XMLStream & xs, OutputParams const & rp) const
 	// Done with the listing.
 	xs.endDivision();
 	xs << xml::EndTag(il.docbooktag());
+	xs << xml::CR();
 }
 
 
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index d672144..808b4cf 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -504,8 +504,6 @@ void makeParagraph(
 	//		or we're not in the last paragraph, anyway.
 	//   (ii) We didn't open it and docbook_in_par is true,
 	//		but we are in the first par, and there is a next par.
-	auto nextpar = par;
-	++nextpar;
 	bool const close_par = open_par && (!runparams.docbook_in_par);
 
 	// Determine if this paragraph has some real content. Things like new pages are not caught
@@ -513,7 +511,9 @@ void makeParagraph(
 	// Thus, remove all spaces (including new lines: \r, \n) before checking for emptiness.
 	// std::all_of allows doing this check without having to copy the string.
 	// Open and close tags around each contained paragraph.
-	auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0);
+	auto nextpar = par;
+	++nextpar;
+	auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end);
 	for (auto & parXML : pars) {
 		if (!std::all_of(parXML.begin(), parXML.end(), ::isspace)) {
 			if (open_par)

commit 029ab977e4564aacc712ed2bac6b04d5e41f434e
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 23:38:40 2020 +0200

    DocBook: fix font issues when a paragraph has an InsetNewline.

diff --git a/autotests/export/docbook/issue5165.xml b/autotests/export/docbook/issue5165.xml
index 2e24ebc..81d840d 100644
--- a/autotests/export/docbook/issue5165.xml
+++ b/autotests/export/docbook/issue5165.xml
@@ -4,9 +4,10 @@
 <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">
 <info>
 <title>Title</title>
-<author><personname>Author</personname></author>
+<author>
+<personname>Author</personname>
+</author>
 <date>Date</date>
 </info>
 <para>Content</para>
-
 </article>
\ No newline at end of file
diff --git a/autotests/export/docbook/labeling_list_nested.xml b/autotests/export/docbook/labeling_list_nested.xml
index 261605c..4ecb1c6 100644
--- a/autotests/export/docbook/labeling_list_nested.xml
+++ b/autotests/export/docbook/labeling_list_nested.xml
@@ -7,22 +7,19 @@
 <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> </para>
+<para />
 </listitem>
 </varlistentry>
 </variablelist>
@@ -30,27 +27,23 @@
 </varlistentry>
 <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> </para>
+<para />
 </listitem>
 </varlistentry>
 </variablelist>
 </listitem>
 </varlistentry>
 </variablelist>
-
 </article>
\ No newline at end of file
diff --git a/autotests/export/docbook/list_depth.xml b/autotests/export/docbook/list_depth.xml
index 3833931..5eaa83c 100644
--- a/autotests/export/docbook/list_depth.xml
+++ b/autotests/export/docbook/list_depth.xml
@@ -1,7 +1,7 @@
 <?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>
 <itemizedlist>
 <listitem>
@@ -9,5 +9,4 @@
 <para>Content.</para>
 </listitem>
 </itemizedlist>
-
-</article>
+</article>
\ No newline at end of file
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index aad1ccf..b4e4bc3 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3358,12 +3358,15 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
 		if (isDeleted(i))
 			continue;
 
-		// If this is an InsetNewline, generate a new paragraph.
+		// If this is an InsetNewline, generate a new paragraph. Also reset the fonts, so that tags are closed in
+		// this paragraph.
 		if (getInset(i) != nullptr && getInset(i)->lyxCode() == NEWLINE_CODE) {
+			xs->closeFontTags();
 			generatedParagraphs.push_back(os.str());
 			os = odocstringstream();
 			delete xs;
 			xs = new XMLStream(os);
+			font_old = outerfont.fontInfo();
 		}
 
 		// Determine which tags should be opened or closed.

commit e64dd22aae50680d258a99ababee48ca7438763c
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 23:29:02 2020 +0200

    DocBook: fix issue with fonts.

diff --git a/autotests/export/docbook/issue1732_charstyles-docbook.xml b/autotests/export/docbook/issue1732_charstyles-docbook.xml
index 0ed9b87..fc9bffe 100644
--- a/autotests/export/docbook/issue1732_charstyles-docbook.xml
+++ b/autotests/export/docbook/issue1732_charstyles-docbook.xml
@@ -3,5 +3,4 @@
   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">
 <para><emphasis role='bold'>Fett </emphasis><emphasis>hervorgehoben</emphasis> <code>monospace</code><emphasis role='underline'> unterstrichen.</emphasis></para>
-
 </article>
\ No newline at end of file
diff --git a/src/xml.cpp b/src/xml.cpp
index 150f4c5..dd9790f 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -208,9 +208,6 @@ bool XMLStream::closeFontTags()
 		if (**curtag != xml::parsep_tag)
 			os_ << (*curtag)->writeEndTag();
 		tag_stack_.pop_back();
-		// this shouldn't happen, since then the font tags
-		// weren't in any other tag.
-		LASSERT(!tag_stack_.empty(), return true);
 		if (tag_stack_.empty())
 			return true;
 		curtag = &tag_stack_.back();

commit 737b1b3269d4aa02a587aa4b5f14ea7309962418
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 22:08:01 2020 +0200

    DocBook: fixes in bibliography (missing new line at the end).

diff --git a/autotests/export/docbook/easy.xml b/autotests/export/docbook/easy.xml
index 883c982..e301321 100644
--- a/autotests/export/docbook/easy.xml
+++ b/autotests/export/docbook/easy.xml
@@ -12,8 +12,9 @@
 <para>I am an abstract</para>
 <para>I am also an abstract</para>
 </abstract>
+
 </info>
-<section xml:id="sec.Sec-1-0">
+<section xml:id="sec.Sec-1">
 <title>I am the first section </title>
 <para>I am the first paragraph of the first section. </para>
 <para>I am the second paragraph of the first section. </para>
@@ -50,7 +51,7 @@
 <section>
 <title>I am the second section </title>
 <para>I am the only paragraph of the second section. <link xlink:href="http://example.org">Hyperlink.</link> “Text between quotes.”</para>
-<para>See <xref linkend="sec.Sec-1-0" />.</para>
+<para>See <xref linkend="sec.Sec-1" />.</para>
 </section>
 <section>
 <title>I am the third section and I deal with star sections</title>
diff --git a/autotests/export/docbook/issue_infinite_loop.xml b/autotests/export/docbook/issue_infinite_loop.xml
index d6e55ee..e262ed4 100644
--- a/autotests/export/docbook/issue_infinite_loop.xml
+++ b/autotests/export/docbook/issue_infinite_loop.xml
@@ -5,7 +5,8 @@
 <title>William Shakespeare</title>
 <section>
 <title>Publications</title>
-<bibliography>First Folio. Me. 1623..</bibliography>
 </section>
-
+<bibliography>
+<bibliomixed xml:id='firstref'>First Folio. Me. 1623..</bibliomixed>
+</bibliography>
 </article>
\ No newline at end of file
diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp
index c03a8e2..05fd23d 100644
--- a/src/insets/InsetBibtex.cpp
+++ b/src/insets/InsetBibtex.cpp
@@ -1411,6 +1411,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const
 
 	// Footer for bibliography.
 	xs << xml::EndTag("bibliography");
+	xs << xml::CR();
 }
 
 

commit 1d62f91bdb193165066bfd25d6e349aeff61b49a
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.

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&#xA0;document&#xA0;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&#xA0;document&#xA0;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&#xA0;valid&#xA0;value&#xA0;for&#xA0;an&#xA0;existing&#xA0;setting,</term>
 <listitem>
-<para> e.&#x2009;g.</para>
+<para>e.&#x2009;g.</para>
 <variablelist>
 <varlistentry>
 <term>Automatically&#xA0;loaded&#xA0;math&#xA0;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&#xA0;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&#xA0;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&#xA0;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&#xA0;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&#xA0;+&#xA0;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&#xA0;+&#xA0;LaTeX&#xA0;+&#xA0;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&#xA0;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;
 	}
 

commit aee969fed0369409dac0224fe2ce95964d06f208
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 21:51:40 2020 +0200

    DocBook: fix titles in KOMA Script.

diff --git a/autotests/export/docbook/description_list_nested.xml b/autotests/export/docbook/description_list_nested.xml
index fc50c2c..ec57aaa 100644
--- a/autotests/export/docbook/description_list_nested.xml
+++ b/autotests/export/docbook/description_list_nested.xml
@@ -6,22 +6,19 @@
 <variablelist>
 <varlistentry>
 <term>New&#xA0;valid&#xA0;value&#xA0;for&#xA0;an&#xA0;existing&#xA0;setting,</term>
-
 <listitem>
-<para> e.&#x2009;g.</para>
+<para>e.&#x2009;g.</para>
 <variablelist>
 <varlistentry>
 <term>Automatically&#xA0;loaded&#xA0;math&#xA0;package</term>
-
 <listitem>
-<para> The reason </para>
+<para>The reason </para>
 </listitem>
 </varlistentry>
 <varlistentry>
 <term>New&#xA0;language</term>
-
 <listitem>
-<para> that is stored</para>
+<para>that is stored</para>
 </listitem>
 </varlistentry>
 </variablelist>
@@ -29,11 +26,9 @@
 </varlistentry>
 <varlistentry>
 <term>New&#xA0;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>
 </variablelist>
-
 </article>
\ No newline at end of file
diff --git a/autotests/export/docbook/deutsches_ert.xml b/autotests/export/docbook/deutsches_ert.xml
index 1d9b725..3e12603 100644
--- a/autotests/export/docbook/deutsches_ert.xml
+++ b/autotests/export/docbook/deutsches_ert.xml
@@ -5,12 +5,19 @@
 <info>
 <title>Erweiterte LyX Features</title>
 <subtitle>Version 2.3.x</subtitle>
-<author><personname>vom LyX-Team<footnote>Übersetzung und Bearbeitung: Hartmut<person> Haase (<person>HHa, bis März 2010),Jürgen Spitzmüller (Version 2.3.x, 2017)</person></person></footnote></personname></author>
+<author>
+<personname>vom LyX-Team<footnote>
+<para>Übersetzung und Bearbeitung: Hartmut<person> </person>Haase (<person>HHa</person>, bis März 2010),</para>
+<para>Jürgen Spitzmüller (Version 2.3.x, 2017)</para>
+</footnote></personname>
+</author>
 </info>
 <chapter>
-<chapter>Einleitung</chapter>
-<para>Wählen Sie hierfür <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;LaTeX-Vorspann. Dies öffnet ein Editierfenster, in das Sie Ihre bevorzugten Befehle schreiben können.<footnote><para>Das Editierverhalten in diesem Fenster ist spezifisch, also erwarten Sie nicht, dass die LyX<!-- „= -->Tastenkombinationen darin funktionieren.</para>
-</footnote> LyX fügt alles im <emphasis role='sans'>LaTeX-Vorspann-Fenster zu seinem eingebauten Vorspann hinzu. Bevor Sie Ihre eigenen Deklarationen zum Vorspann hinzufügen, sollten Sie prüfen, ob LyX das nicht bereits unterstützt (Erinnern Sie sich, was wir über das Rad noch einmal erfinden sagten?). Außerdem: <emphasis>stellen Sie sicher, dass Ihre Vorspannzeilen richtig sind. LyX prüft das nicht. Wenn der Vorspann fehlerhaft ist, bekommen Sie sehr wahrscheinlich die Fehlermeldung Missing \begin{document}. Sollten Sie diese jemals bekommen, prüfen Sie Ihren Vorspann!. <!-- -- --></emphasis></emphasis></emphasis></para>
+<title>Einleitung</title>
+<para>Wählen Sie hierfür <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;LaTeX-Vorspann.</emphasis> Dies öffnet ein Editierfenster, in das Sie Ihre bevorzugten Befehle schreiben können.<footnote>
+<para>Das Editierverhalten in diesem Fenster ist spezifisch, also erwarten Sie nicht, dass die LyX<!-- „= -->
+Tastenkombinationen darin funktionieren.</para>
+</footnote> LyX fügt alles im <emphasis role='sans'>LaTeX-Vorspann</emphasis>-Fenster zu seinem eingebauten Vorspann hinzu. Bevor Sie Ihre eigenen Deklarationen zum Vorspann hinzufügen, sollten Sie prüfen, ob LyX das nicht bereits unterstützt (Erinnern Sie sich, was wir über das Rad noch einmal erfinden sagten?). Außerdem: <emphasis>stellen Sie sicher, dass Ihre Vorspannzeilen richtig sind</emphasis>. LyX prüft das nicht. Wenn der Vorspann fehlerhaft ist, bekommen Sie sehr wahrscheinlich die Fehlermeldung Missing \begin{document}. Sollten Sie diese jemals bekommen, prüfen Sie Ihren Vorspann!. <!-- -- -->
+</para>
 </chapter>
-
 </book>
\ No newline at end of file
diff --git a/lib/layouts/scrartcl.layout b/lib/layouts/scrartcl.layout
index 1b27e89..4f2a8d4 100644
--- a/lib/layouts/scrartcl.layout
+++ b/lib/layouts/scrartcl.layout
@@ -26,7 +26,9 @@ Style Part
 	Font
 	  Size		Larger
 	EndFont
-	DocBookTag            part
+	DocBookTag            title
+	DocBookTagType        paragraph
+	DocBookSectionTag     part
 End
 
 Style Part*
@@ -36,5 +38,7 @@ Style Part*
 	Font
 	  Size		Larger
 	EndFont
-	DocBookTag            part
+	DocBookTag            title
+	DocBookTagType        paragraph
+	DocBookSectionTag     part
 End
diff --git a/lib/layouts/scrbook.layout b/lib/layouts/scrbook.layout
index 60caa1c..01d16ca 100644
--- a/lib/layouts/scrbook.layout
+++ b/lib/layouts/scrbook.layout
@@ -18,7 +18,9 @@ NoStyle Abstract
 Style Chapter
 	LabelString	"\thechapter"
 	TocLevel 0
-	DocBookTag            chapter
+	DocBookTag            title
+	DocBookTagType        paragraph
+	DocBookSectionTag     chapter
 End
 
 
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 2bffb0a..cf76bf4 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -978,6 +978,9 @@ void outputDocBookInfo(
 
 	// End the <info> tag if it was started.
 	if (needInfo) {
+		if (!xs.isLastTagCR())
+			xs << xml::CR();
+
 		xs << xml::EndTag("info");
 		xs << xml::CR();
 		xs.endDivision();

commit 6b55e5dd84054e96ccd2eae0fd490d86d37c6a5f
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 03:30:56 2020 +0200

    DocBook: bug fixing with wrapper merging.

diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml
index 70b19af..2ab4a79 100644
--- a/autotests/export/docbook/bibliography_precooked_aastex.xml
+++ b/autotests/export/docbook/bibliography_precooked_aastex.xml
@@ -40,16 +40,15 @@
 <affiliation role="alternate">
 <orgname>Patron, Alonso's Bar and Grill</orgname>
 </affiliation>
-<keyword>
-clusters: globular, peanut—bosons: bozos
-</keyword>
-<!-- Output Error: Tried to close `keywordset' when tag was not open. Tag discarded. -->
-
+</author>
+<keywordset>
+<keyword>clusters: globular, peanut—bosons: bozos</keyword>
+</keywordset>
+<abstract>
 <para>This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. </para>
+</abstract>
 
-<!-- Output Error: Closing tag `info' when other tags are open, namely: -->
-<!-- Output Error: author -->
-</author></info>
+</info>
 <section>
 <title>Introduction</title>
 <para>A focal problem today in the dynamics of globular clusters is core collapse. It has been predicted by theory for decades <biblioref endterm="hen61" />, <biblioref endterm="lyn68" />, <biblioref endterm="spi85" />, but observation has been less alert to the phenomenon. For many years the central brightness peak in M15 <biblioref endterm="kin75" />, <biblioref endterm="new78" /> seemed a unique anomaly. Then <biblioref endterm="aur82" /> suggested a central peak in NGC 6397, and a limited photographic survey of ours <biblioref endterm="djo84" /> found three more cases, including NGC 6624, whose sharp center had often been remarked on <biblioref endterm="can78" />. </para>
@@ -1005,11 +1004,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
 </inlineequation> of the electronically submitted abstracts for AAS meetings are error-free. </para>
 <acknowledgements>
 <para>We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section&#xA0;<xref linkend="bozomath" />. More information on the AASTeX macros package are available at <link xlink:href="http://www.aas.org/publications/aastex">http://www.aas.org/publications/aastex</link> or the <link xlink:href="ftp://www.aas.org/pubs/AAS ftp site">AAS ftp site</link>.</para>
-<application>
-IRAF, AIPS, Astropy, ...
-</application>
-<!-- Output Error: Tried to close `para' when tag was not open. Tag discarded. -->
-
+</acknowledgements>
+<remark role='software'>IRAF, AIPS, Astropy, ...</remark>
 </section>
 <bibliography>
 <bibliomixed xml:id='aur82'>Aurière, M. 1982, <!-- \aap -->
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 19bd1d8..2bffb0a 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -274,8 +274,10 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar
 	if (prevpar != nullptr) {
 		Layout const & prevlay = prevpar->layout();
 		if (prevlay.docbookwrappertag() != "NONE") {
-			openWrapper = prevlay.docbookwrappertag() == lay.docbookwrappertag()
-			              && !lay.docbookwrappermergewithprevious();
+			if (prevlay.docbookwrappertag() == lay.docbookwrappertag())
+				openWrapper = !lay.docbookwrappermergewithprevious();
+			else
+				openWrapper = true;
 		}
 	}
 
@@ -308,8 +310,10 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa
 	if (nextpar != nullptr) {
 		Layout const & nextlay = nextpar->layout();
 		if (nextlay.docbookwrappertag() != "NONE") {
-			closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag()
-			               && !nextlay.docbookwrappermergewithprevious();
+			if (nextlay.docbookwrappertag() == lay.docbookwrappertag())
+				closeWrapper = !nextlay.docbookwrappermergewithprevious();
+			else
+				closeWrapper = true;
 		}
 	}
 
@@ -948,8 +952,7 @@ void outputDocBookInfo(
 		// that mandating a wrapper like <info> would repel users. Thus, generate them first.
 		makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit));
 	for (auto pit : info.mustBeInInfo)
-		if (info.abstract.find(pit) == info.abstract.end()) // The abstract must be in info, but is dealt with after.
-			makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit));
+		makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit));
 
 	// Always output the abstract as the last item of the <info>, as it requires special treatment (especially if
 	// it contains several paragraphs that are empty).

commit 154a3a5c76df995a16ff252f4a42d591c523789e
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 03:08:55 2020 +0200

    DocBook: bug fixing in AASTeX layout.
    
    That's mostly generating DocBook tags at an inappropriate place with some metadata, rather than outputting whatever you have at your disposal. Far from satisfying, but good enough for a generic tool (see details in the new TODO). Doesn't trigger assertions. Is valid XML.

diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml
index 71fe700..70b19af 100644
--- a/autotests/export/docbook/bibliography_precooked_aastex.xml
+++ b/autotests/export/docbook/bibliography_precooked_aastex.xml
@@ -382,9 +382,7 @@ clusters: globular, peanut—bosons: bozos
  </m:mrow>
  </m:math>
 </inlineequation> may be formed from particle four-momenta, gauge-boson polarization vectors or fermion strings with an uncontracted Lorentz index associated with final-state fermions.</para>
-<NoteToEditor>
-Figures 1 and 2 should appear side-by-side in print
-</NoteToEditor>
+<remark role='to-editor'>Figures 1 and 2 should appear side-by-side in print</remark>
 <para>In the chiral representation the <inlineequation>
 <alt role='tex'>\gamma</alt>
  <m:math>
@@ -634,7 +632,6 @@ Figures 1 and 2 should appear side-by-side in print
  </m:mrow>
  </m:math>
 </inlineequation> by </para>
-<MathLetters>
 <informalequation>
 <alt role='tex'>u(p,\lambda)_{\pm} & = & (E\pm\lambda|{\textbf{p}}|)^{1/2}\chi_{\lambda}(p),\\
 v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi_{-\lambda}(p)
@@ -724,9 +721,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
   </m:mtr>
  </m:mtable>
  </m:math>
-</informalequation>
-</MathLetters>
-</section>
+</informalequation></section>
 </section>
 <section>
 <title>Floating material and so forth</title>
@@ -1008,7 +1003,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation> of the electronically submitted abstracts for AAS meetings are error-free. </para>
-<acknowledgement>
+<acknowledgements>
 <para>We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section&#xA0;<xref linkend="bozomath" />. More information on the AASTeX macros package are available at <link xlink:href="http://www.aas.org/publications/aastex">http://www.aas.org/publications/aastex</link> or the <link xlink:href="ftp://www.aas.org/pubs/AAS ftp site">AAS ftp site</link>.</para>
 <application>
 IRAF, AIPS, Astropy, ...
@@ -1139,7 +1134,7 @@ IRAF, AIPS, Astropy, ...
  <m:mrow><m:mi>P</m:mi>
  </m:mrow>
  </m:math>
-</inlineequation>a</td>
+</inlineequation><remark role='tablenotemark'>a</remark></td>
 <td align='right' valign='top'> <inlineequation>
 <alt role='tex'>PR_{maj}</alt>
  <m:math>
@@ -1183,7 +1178,7 @@ IRAF, AIPS, Astropy, ...
  <m:mrow><m:mo>&#x398;</m:mo>
  </m:mrow>
  </m:math>
-</inlineequation>b</td>
+</inlineequation><remark role='tablenotemark'>b</remark></td>
 <td align='center' valign='top'>Ref.</td>
 </tr>
 <tr>
@@ -1235,7 +1230,7 @@ IRAF, AIPS, Astropy, ...
 <tr>
 <td align='center' valign='top'> 4 </td>
 <td align='right' valign='top'>32733.8 </td>
-<td align='right' valign='top'>-1.2c</td>
+<td align='right' valign='top'>-1.2<remark role='tablenotemark'>c</remark></td>
 <td align='right' valign='top'>-0.5 </td>
 <td align='right' valign='top'>41 </td>
 <td align='right' valign='top'>54.8 </td>
@@ -1254,7 +1249,7 @@ IRAF, AIPS, Astropy, ...
 <td align='right' valign='top'>-0.4 </td>
 <td align='right' valign='top'>60 </td>
 <td align='right' valign='top'>1.4 </td>
-<td align='right' valign='top'>1.669c</td>
+<td align='right' valign='top'>1.669<remark role='tablenotemark'>c</remark></td>
 <td align='right' valign='top'>1.574 </td>
 <td align='right' valign='top'>2.343 </td>
 <td align='right' valign='top'>8.0 </td>
@@ -1279,23 +1274,13 @@ IRAF, AIPS, Astropy, ...
 </tr>
 </tbody>
 
-<Table note>
-a<!-- }{ -->
-Sample footnote for table&#xA0;<xref linkend="tbl-2" /> that was generated with the LaTeX table environment
-</Table note>
-<Table note>
-b<!-- }{ -->
-Yet another sample footnote for table&#xA0;<xref linkend="tbl-2" />
-</Table note>
-<Table note>
-c<!-- }{ -->
-Another sample footnote for table&#xA0;<xref linkend="tbl-2" />
-</Table note>
-<TableComments>
-We can also attach a long-ish paragraph of explanatory material to a table. Use \tablerefs to append a list of references. The following references were from a different table: I've patched them in here to show how they look, but don't take them too seriously—I certainly have not.
-</TableComments>
-<TableRefs>
-(1) Barbuy, Spite, & Spite 1985; (2) Bond 1980; (3) Carbon et al. 1987; (4) Hobbs & Duncan 1987; (5) Gilroy et al. 1988: (6) Gratton & Ortolani 1986; (7) Gratton & Sneden 1987; (8) Gratton & Sneden (1988); (9) Gratton & Sneden 1991; (10) Kraft et al. 1982; (11) LCL, or Laird, 1990; (12) Leep & Wallerstein 1981; (13) Luck & Bond 1981; (14) Luck & Bond 1985; (15) Magain 1987; (16) Magain 1989; (17) Peterson 1981; (18) Peterson, Kurucz, & Carney 1990; (19) RMB; (20) Schuster & Nissen 1988; (21) Schuster & Nissen 1989b; (22) Spite et al. 1984; (23) Spite & Spite 1986; (24) Hobbs & Thorburn 1991; (25) Hobbs et al. 1991; (26) Olsen 1983.
-</TableRefs>
+<remark role='tablenote'>a<!-- }{ -->
+Sample footnote for table&#xA0;<xref linkend="tbl-2" /> that was generated with the LaTeX table environment</remark>
+<remark role='tablenote'>b<!-- }{ -->
+Yet another sample footnote for table&#xA0;<xref linkend="tbl-2" /></remark>
+<remark role='tablenote'>c<!-- }{ -->
+Another sample footnote for table&#xA0;<xref linkend="tbl-2" /></remark>
+<remark role='tablecomments'>We can also attach a long-ish paragraph of explanatory material to a table. Use \tablerefs to append a list of references. The following references were from a different table: I've patched them in here to show how they look, but don't take them too seriously—I certainly have not.</remark>
+<remark role='tablerefs'>(1) Barbuy, Spite, & Spite 1985; (2) Bond 1980; (3) Carbon et al. 1987; (4) Hobbs & Duncan 1987; (5) Gilroy et al. 1988: (6) Gratton & Ortolani 1986; (7) Gratton & Sneden 1987; (8) Gratton & Sneden (1988); (9) Gratton & Sneden 1991; (10) Kraft et al. 1982; (11) LCL, or Laird, 1990; (12) Leep & Wallerstein 1981; (13) Luck & Bond 1981; (14) Luck & Bond 1985; (15) Magain 1987; (16) Magain 1989; (17) Peterson 1981; (18) Peterson, Kurucz, & Carney 1990; (19) RMB; (20) Schuster & Nissen 1988; (21) Schuster & Nissen 1989b; (22) Spite et al. 1984; (23) Spite & Spite 1986; (24) Hobbs & Thorburn 1991; (25) Hobbs et al. 1991; (26) Olsen 1983.</remark>
 </table>
 </article>
\ No newline at end of file
diff --git a/development/DocBookToDo b/development/DocBookToDo
new file mode 100644
index 0000000..39ca534
--- /dev/null
+++ b/development/DocBookToDo
@@ -0,0 +1,20 @@
+Things specific to layouts
+==========================
+
+AASTeX
+------
+
+No support for table notes. They could be implemented through <footnoteref>, but it becomes a nightmare to ensure xml:id uniqueness (the only ID available here is in the inset; mix it with the table ID?). Anyway, it would require a lot of specific code to make it work, probably not worth the effort right now. 
+
+	Related parts of the layout: 
+		Style "Table note"
+		InsetLayout "Flex:tablenotemark"
+	Alreayd used in the following test: 
+		bibliography_precooked_aastex.lyx
+		
+Notion of MathLetters: a group of equations. No good mapping in DocBook, maybe an informalgroup? To discuss with DocBook TC. 
+TableRefs, TableComments: no mapping in DocBook, not really a way to add these things. To discuss with DocBook TC. 
+
+Clearly, with this kind of template, we're reaching the limits of such a system! Having a really good converter for all these cases would require a lot of very specific code. 
+
+More general: what the heck with appendices? It's not handled in the LyX way (Document > Start Appendix Here), but in a custom way. Making this work would solve some correctness issues with this template. 
\ No newline at end of file
diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout
index d79cd02..78089a4 100644
--- a/lib/layouts/aastex.layout
+++ b/lib/layouts/aastex.layout
@@ -285,6 +285,11 @@ Style Abstract
 	  Series	Bold
 	  Size		Normal
 	EndFont
+	DocBookAbstract       true
+	DocBookInInfo         always
+	DocBookWrapperTag     abstract
+	DocBookWrapperMergeWithPrevious    true
+	DocBookTag            para
 End
 
 
@@ -335,6 +340,7 @@ Style Keywords
 	  Size		Normal
 	EndFont
 	DocBookTag          keyword
+	DocBookTagType      paragraph
 	DocBookWrapperTag   keywordset
 	DocBookInInfo       always
 End
@@ -359,7 +365,7 @@ Style Acknowledgements
 	  Shape		Italic
 	EndFont
 	DocBookTag            para
-	DocBookWrapperTag     acknowledgement
+	DocBookWrapperTag     acknowledgements
 End
 
 
@@ -432,6 +438,7 @@ Style MathLetters
 	Font
 	  Size		Normal
 	EndFont
+	DocBookTag  NONE
 End
 
 
@@ -495,6 +502,9 @@ Style NoteToEditor
 	  Size		Normal
 	  Shape		Italic
 	EndFont
+	DocBookTag      remark
+	DocBookTagType  paragraph
+	DocBookAttr     role='to-editor'
 End
 
 
@@ -515,6 +525,9 @@ Style TableRefs
 	  Family	Roman
 	  Size		Normal
 	EndFont
+	DocBookTag      remark
+	DocBookTagType  paragraph
+	DocBookAttr     role='tablerefs'
 End
 
 
@@ -535,6 +548,9 @@ Style TableComments
 	  Family	Roman
 	  Size		Normal
 	EndFont
+	DocBookTag      remark
+	DocBookTagType  paragraph
+	DocBookAttr     role='tablecomments'
 End
 
 
@@ -550,6 +566,9 @@ Style "Table note"
 	LabelFont
 	  Color		magenta
 	EndFont
+	DocBookTag      remark
+	DocBookTagType  paragraph
+	DocBookAttr     role='tablenote'
 End
 
 
@@ -572,6 +591,9 @@ InsetLayout "Flex:tablenotemark"
 	  Color		magenta
 	  Size		Small
 	EndFont
+	DocBookTag      remark
+	DocBookTagType  paragraph
+	DocBookAttr     role='tablenotemark'
 End
 
 
diff --git a/lib/layouts/aastex6.layout b/lib/layouts/aastex6.layout
index 03d585e..6935365 100644
--- a/lib/layouts/aastex6.layout
+++ b/lib/layouts/aastex6.layout
@@ -67,8 +67,11 @@ Style Software
 	LabelFont
 	  Shape		Italic
 	EndFont
-	DocBookWrapperTag   para
-	DocBookTag          application
+	DocBookTag      remark
+	DocBookAttr     role='software'
+	# Override what's taken from Keywords, but not really wanted.
+	DocBookWrapperTag   NONE
+	DocBookInInfo       never
 End
 
 # other new commands are mainly for the user preamble
diff --git a/lib/layouts/aastex62.layout b/lib/layouts/aastex62.layout
index 3eb7dcc..1ef8636 100644
--- a/lib/layouts/aastex62.layout
+++ b/lib/layouts/aastex62.layout
@@ -78,8 +78,11 @@ Style Software
 	LabelFont
 		Shape           Italic
 	EndFont
-	DocBookWrapperTag   para
-	DocBookTag          application
+	DocBookTag      remark
+	DocBookAttr     role='software'
+	# Override what's taken from Keywords, but not really wanted.
+	DocBookWrapperTag   NONE
+	DocBookInInfo       never
 End
 
 # other new commands are mainly for the user preamble

commit dd82fe02e617c44e3524d343bf2f5ea39e5a2865
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 02:34:49 2020 +0200

    DocBook: adapt AASTeX for tag types (new-line behaviour).

diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml
index fe77b72..71fe700 100644
--- a/autotests/export/docbook/bibliography_precooked_aastex.xml
+++ b/autotests/export/docbook/bibliography_precooked_aastex.xml
@@ -3,25 +3,53 @@
   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">
 <info>
-<!-- shouldBeInInfo --><title>Collapsed Cores in Globular Clusters,  Gauge-Boson Couplings, and AASTeX Examples</title>
-<!-- mustBeInInfo --><author><personname>S. Djorgovski and Ivan R. King</personname>
-<affiliation><orgname>Astronomy Department, University of California, Berkeley, CA 94720</orgname></affiliation>
-<affiliation role="alternate"><orgname>Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation.</orgname></affiliation>
-<affiliation role="alternate"><orgname>Society of Fellows, Harvard University.</orgname></affiliation>
-<affiliation role="alternate"><orgname>present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138</orgname></affiliation></author>
-<author><personname>C. D. Biemesderfer</personname>
-<affiliation><orgname>National Optical Astronomy Observatories, Tucson, AZ 85719</orgname></affiliation>
-<affiliation role="alternate"><orgname>Visiting Programmer, Space Telescope Science Institute</orgname></affiliation>
-<affiliation role="alternate"><orgname>Patron, Alonso's Bar and Grill</orgname></affiliation>
-<email>aastex-help at aas.org</email></author>
-<author><personname>R. J. Hanisch</personname>
-<affiliation><orgname>Space Telescope Science Institute, Baltimore, MD 21218</orgname></affiliation>
-<affiliation role="alternate"><orgname>Patron, Alonso's Bar and Grill</orgname></affiliation></author>
-<keywordset><keyword>clusters: globular, peanut—bosons: bozos</keyword></keywordset>
-<!-- /info --><!-- abs --><abstract><para>
+<title>Collapsed Cores in Globular Clusters,  Gauge-Boson Couplings, and AASTeX Examples</title>
+<author>
+<personname>S. Djorgovski and Ivan R. King</personname>
+<affiliation>
+<orgname>Astronomy Department, University of California, Berkeley, CA 94720</orgname>
+</affiliation>
+<affiliation role="alternate">
+<orgname>Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation.</orgname>
+</affiliation>
+<affiliation role="alternate">
+<orgname>Society of Fellows, Harvard University.</orgname>
+</affiliation>
+<affiliation role="alternate">
+<orgname>present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138</orgname>
+</affiliation>
+</author>
+<author>
+<personname>C. D. Biemesderfer</personname>
+<affiliation>
+<orgname>National Optical Astronomy Observatories, Tucson, AZ 85719</orgname>
+</affiliation>
+<affiliation role="alternate">
+<orgname>Visiting Programmer, Space Telescope Science Institute</orgname>
+</affiliation>
+<affiliation role="alternate">
+<orgname>Patron, Alonso's Bar and Grill</orgname>
+</affiliation>
+<email>aastex-help at aas.org</email>
+</author>
+<author>
+<personname>R. J. Hanisch</personname>
+<affiliation>
+<orgname>Space Telescope Science Institute, Baltimore, MD 21218</orgname>
+</affiliation>
+<affiliation role="alternate">
+<orgname>Patron, Alonso's Bar and Grill</orgname>
+</affiliation>
+<keyword>
+clusters: globular, peanut—bosons: bozos
+</keyword>
+<!-- Output Error: Tried to close `keywordset' when tag was not open. Tag discarded. -->
+
 <para>This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. </para>
-</para></abstract>
-<!-- 15 --><!-- /abs --></info>
+
+<!-- Output Error: Closing tag `info' when other tags are open, namely: -->
+<!-- Output Error: author -->
+</author></info>
 <section>
 <title>Introduction</title>
 <para>A focal problem today in the dynamics of globular clusters is core collapse. It has been predicted by theory for decades <biblioref endterm="hen61" />, <biblioref endterm="lyn68" />, <biblioref endterm="spi85" />, but observation has been less alert to the phenomenon. For many years the central brightness peak in M15 <biblioref endterm="kin75" />, <biblioref endterm="new78" /> seemed a unique anomaly. Then <biblioref endterm="aur82" /> suggested a central peak in NGC 6397, and a limited photographic survey of ours <biblioref endterm="djo84" /> found three more cases, including NGC 6624, whose sharp center had often been remarked on <biblioref endterm="can78" />. </para>
@@ -107,7 +135,8 @@
 </section>
 <section>
 <title>Helicity Amplitudes</title>
-<para>It has been realized that helicity amplitudes provide a convenient means for Feynman diagram<footnote><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --><para>Footnotes can be inserted like this.</para>
+<para>It has been realized that helicity amplitudes provide a convenient means for Feynman diagram<footnote>
+<para>Footnotes can be inserted like this.</para>
 </footnote> evaluations. These amplitude-level techniques are particularly convenient for calculations involving many Feynman diagrams, where the usual trace techniques for the amplitude squared becomes unwieldy. Our calculations use the helicity techniques developed by other authors <biblioref endterm="hag86" />; we briefly summarize below.</para>
 <section>
 <title>Formalism</title>
@@ -133,7 +162,8 @@
   </m:mrow>
  </m:mrow>
  </m:math>
-</inlineequation> collisions can be expressed in terms of fermion strings of the form <informalequation>
+</inlineequation> collisions can be expressed in terms of fermion strings of the form 
+<informalequation>
 <alt role='tex'>\bar{v}(p_{2},\sigma_{2})P_{-\tau}\hat{a}_{1}\hat{a}_{2}\cdots\hat{a}_{n}u(p_{1},\sigma_{1}),</alt>
  <m:math>
  
@@ -352,7 +382,9 @@
  </m:mrow>
  </m:math>
 </inlineequation> may be formed from particle four-momenta, gauge-boson polarization vectors or fermion strings with an uncontracted Lorentz index associated with final-state fermions.</para>
-<NoteToEditor>Figures 1 and 2 should appear side-by-side in print</NoteToEditor>
+<NoteToEditor>
+Figures 1 and 2 should appear side-by-side in print
+</NoteToEditor>
 <para>In the chiral representation the <inlineequation>
 <alt role='tex'>\gamma</alt>
  <m:math>
@@ -376,7 +408,8 @@
  <m:mrow><m:mi>&#x3C3;</m:mi>
  </m:mrow>
  </m:math>
-</inlineequation> and the unit matrix 1 as <informalequation>
+</inlineequation> and the unit matrix 1 as 
+<informalequation>
 <alt role='tex'>\gamma^{\mu} & = & \left(\begin{array}{cc}
 0 & \sigma_{+}^{\mu}\\
 \sigma_{-}^{\mu} & 0
@@ -486,7 +519,8 @@
   </m:mtr>
  </m:mtable>
  </m:math>
-</informalequation> giving <informalequation>
+</informalequation> giving 
+<informalequation>
 <alt role='tex'>\hat{a}=\left(\begin{array}{cc}
 0 & (\hat{a})_{+}\\
 (\hat{a})_{-} & 0
@@ -564,11 +598,13 @@
   </m:mrow>
  </m:mrow>
  </m:math>
-</informalequation> The spinors are expressed in terms of two-component Weyl spinors as <informalequation>
+</informalequation> The spinors are expressed in terms of two-component Weyl spinors as 
+<informalequation>
 <alt role='tex'>u=\left(\begin{array}{c}
 (u)_{-}\\
 (u)_{+}
-\end{array}\right),v={\textbf{(}}\vdag_{+}{\textbf{,}}\vdag_{-}{\textbf{)}}.</alt>MathML export failed. Please report this as a bug.
+\end{array}\right),v={\textbf{(}}\vdag_{+}{\textbf{,}}\vdag_{-}{\textbf{)}}.</alt>
+<mathphrase>MathML export failed. Please report this as a bug.</mathphrase>
 </informalequation></para>
 <para>The Weyl spinors are given in terms of helicity eigenstates <inlineequation>
 <alt role='tex'>\chi_{\lambda}(p)</alt>
@@ -694,7 +730,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
 </section>
 <section>
 <title>Floating material and so forth</title>
-<para>Consider a task that computes profile parameters for a modified Lorentzian of the form <informalequation>
+<para>Consider a task that computes profile parameters for a modified Lorentzian of the form 
+<informalequation>
 <alt role='tex'>I=\frac{1}{1+d_{1}^{P(1+d_{2})}}</alt>
  <m:math>
  
@@ -732,7 +769,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
   </m:mrow>
  </m:mrow>
  </m:math>
-</informalequation> where <informalequation>
+</informalequation> where 
+<informalequation>
 <alt role='tex'>d_{1}=\sqrt{\left(\begin{array}{c}
 \frac{x_{1}}{R_{maj}}\end{array}\right)^{2}+\left(\begin{array}{c}
 \frac{y_{1}}{R_{min}}\end{array}\right)^{2}}</alt>
@@ -817,11 +855,14 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
   </m:mrow>
  </m:mrow>
  </m:math>
-</informalequation><informalequation>
+</informalequation>
+<informalequation>
 <alt role='tex'>d_{2}=\sqrt{\left(\begin{array}{c}
 \frac{x_{1}}{PR_{maj}}\end{array}\right)^{2}+\left(\begin{array}{c}
-\case{y_{1}}{PR_{min}}\end{array}\right)^{2}}</alt>MathML export failed. Please report this as a bug.
-</informalequation><informalequation>
+\case{y_{1}}{PR_{min}}\end{array}\right)^{2}}</alt>
+<mathphrase>MathML export failed. Please report this as a bug.</mathphrase>
+</informalequation>
+<informalequation>
 <alt role='tex'>x_{1}=(x-x_{0})\cos\Theta+(y-y_{0})\sin\Theta</alt>
  <m:math>
  
@@ -858,7 +899,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
   </m:mrow>
  </m:mrow>
  </m:math>
-</informalequation><informalequation>
+</informalequation>
+<informalequation>
 <alt role='tex'>y_{1}=-(x-x_{0})\sin\Theta+(y-y_{0})\cos\Theta</alt>
  <m:math>
  
@@ -951,7 +993,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
   </m:msub>
  </m:mrow>
  </m:math>
-</inlineequation>, but the assumption is that the alternate results should be less than 90° out of phase with previous values. We have no observations of <!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --><!-- \ion{Ca}{2} -->. Roughly <inlineequation>
+</inlineequation>, but the assumption is that the alternate results should be less than 90° out of phase with previous values. We have no observations of <!-- \ion{Ca}{2} -->
+. Roughly <inlineequation>
 <alt role='tex'>\nicefrac{4}{5}</alt>
  <m:math>
  
@@ -965,33 +1008,49 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation> of the electronically submitted abstracts for AAS meetings are error-free. </para>
-<acknowledgement><para>We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section&#xA0;<xref linkend="bozomath" />. More information on the AASTeX macros package are available at <link xlink:href="http://www.aas.org/publications/aastex"><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->http://www.aas.org/publications/aastex</link> or the <link xlink:href="ftp://www.aas.org/pubs/AAS ftp site">AAS ftp site</link>.</para>
-<application>IRAF, AIPS, Astropy, ...</application><!-- Output Error: Tried to close `para' when tag was not open. Tag discarded. -->
+<acknowledgement>
+<para>We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section&#xA0;<xref linkend="bozomath" />. More information on the AASTeX macros package are available at <link xlink:href="http://www.aas.org/publications/aastex">http://www.aas.org/publications/aastex</link> or the <link xlink:href="ftp://www.aas.org/pubs/AAS ftp site">AAS ftp site</link>.</para>
+<application>
+IRAF, AIPS, Astropy, ...
+</application>
+<!-- Output Error: Tried to close `para' when tag was not open. Tag discarded. -->
 
+</section>
 <bibliography>
-<bibliomixed xml:id='aur82'>Aurière, M. 1982, <!-- \aap -->, 109, 301 </bibliomixed>
-<bibliomixed xml:id='can78'>Canizares, C. R., Grindlay, J. E., Hiltner, W. A., Liller, W., and McClintock, J. E. 1978, <!-- \apj -->, 224, 39 </bibliomixed>
-<bibliomixed xml:id='djo84'>Djorgovski, S., and King, I. R. 1984, <!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --><!-- \apjl -->, 277, L49 </bibliomixed>
+<bibliomixed xml:id='aur82'>Aurière, M. 1982, <!-- \aap -->
+, 109, 301 </bibliomixed>
+<bibliomixed xml:id='can78'>Canizares, C. R., Grindlay, J. E., Hiltner, W. A., Liller, W., and McClintock, J. E. 1978, <!-- \apj -->
+, 224, 39 </bibliomixed>
+<bibliomixed xml:id='djo84'>Djorgovski, S., and King, I. R. 1984, <!-- \apjl -->
+, 277, L49 </bibliomixed>
 <bibliomixed xml:id='hag86'>Hagiwara, K., and Zeppenfeld, D. 1986, Nucl.Phys., 274, 1 </bibliomixed>
-<bibliomixed xml:id='har84'>Harris, W. E., and van den Bergh, S. 1984, <!-- \aj -->, 89, 1816 </bibliomixed>
+<bibliomixed xml:id='har84'>Harris, W. E., and van den Bergh, S. 1984, <!-- \aj -->
+, 89, 1816 </bibliomixed>
 <bibliomixed xml:id='hen61'>Hénon, M. 1961, Ann.d'Ap., 24, 369 </bibliomixed>
-<bibliomixed xml:id='kin66'>King, I. R. 1966, <!-- \aj -->, 71, 276 </bibliomixed>
+<bibliomixed xml:id='kin66'>King, I. R. 1966, <!-- \aj -->
+, 71, 276 </bibliomixed>
 <bibliomixed xml:id='kin75'>King, I. R. 1975, Dynamics of Stellar Systems, A. Hayli, Dordrecht: Reidel, 1975, 99 </bibliomixed>
-<bibliomixed xml:id='kin68'>King, I. R., Hedemann, E., Hodge, S. M., and White, R. E. 1968, <!-- \aj -->, 73, 456 </bibliomixed>
-<bibliomixed xml:id='kro84'>Kron, G. E., Hewitt, A. V., and Wasserman, L. H. 1984, <!-- \pasp -->, 96, 198 </bibliomixed>
-<bibliomixed xml:id='lyn68'>Lynden-Bell, D., and Wood, R. 1968, <!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --><!-- \mnras -->, 138, 495 </bibliomixed>
-<bibliomixed xml:id='new78'>Newell, E. B., and O'Neil, E. J. 1978, <!-- \apjs -->, 37, 27 </bibliomixed>
-<bibliomixed xml:id='ort85'>Ortolani, S., Rosino, L., and Sandage, A. 1985, <!-- \aj -->, 90, 473 </bibliomixed>
-<bibliomixed xml:id='pet76'>Peterson, C. J. 1976, <!-- \aj -->, 81, 617 </bibliomixed>
+<bibliomixed xml:id='kin68'>King, I. R., Hedemann, E., Hodge, S. M., and White, R. E. 1968, <!-- \aj -->
+, 73, 456 </bibliomixed>
+<bibliomixed xml:id='kro84'>Kron, G. E., Hewitt, A. V., and Wasserman, L. H. 1984, <!-- \pasp -->
+, 96, 198 </bibliomixed>
+<bibliomixed xml:id='lyn68'>Lynden-Bell, D., and Wood, R. 1968, <!-- \mnras -->
+, 138, 495 </bibliomixed>
+<bibliomixed xml:id='new78'>Newell, E. B., and O'Neil, E. J. 1978, <!-- \apjs -->
+, 37, 27 </bibliomixed>
+<bibliomixed xml:id='ort85'>Ortolani, S., Rosino, L., and Sandage, A. 1985, <!-- \aj -->
+, 90, 473 </bibliomixed>
+<bibliomixed xml:id='pet76'>Peterson, C. J. 1976, <!-- \aj -->
+, 81, 617 </bibliomixed>
 <bibliomixed xml:id='spi85'>Spitzer, L. 1985, Dynamics of Star Clusters, J. Goodman and P. Hut, Dordrecht: Reidel, 109 </bibliomixed>
 </bibliography>
 <table xml:id="tbl-2">
-<caption><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->Terribly relevant tabular information.</caption>
-<!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --><tbody>
+<caption>Terribly relevant tabular information.</caption>
+<tbody>
 <tr>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->Star </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> Height </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> <inlineequation>
+<td align='center' valign='top'>Star </td>
+<td align='right' valign='top'> Height </td>
+<td align='right' valign='top'> <inlineequation>
 <alt role='tex'>d_{x}</alt>
  <m:math>
  
@@ -1005,7 +1064,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation></td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> <inlineequation>
+<td align='right' valign='top'> <inlineequation>
 <alt role='tex'>d_{y}</alt>
  <m:math>
  
@@ -1019,7 +1078,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation></td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> <inlineequation>
+<td align='right' valign='top'> <inlineequation>
 <alt role='tex'>n</alt>
  <m:math>
  
@@ -1027,7 +1086,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation></td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> <inlineequation>
+<td align='right' valign='top'> <inlineequation>
 <alt role='tex'>\chi^{2}</alt>
  <m:math>
  
@@ -1041,7 +1100,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation></td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> <inlineequation>
+<td align='right' valign='top'> <inlineequation>
 <alt role='tex'>R_{maj}</alt>
  <m:math>
  
@@ -1057,7 +1116,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation></td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> <inlineequation>
+<td align='right' valign='top'> <inlineequation>
 <alt role='tex'>R_{min}</alt>
  <m:math>
  
@@ -1073,15 +1132,15 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation></td>
-<td align='center' valign='top' colspan='1'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --><inlineequation>
+<td align='center' valign='top' colspan='1'><inlineequation>
 <alt role='tex'>P</alt>
  <m:math>
  
  <m:mrow><m:mi>P</m:mi>
  </m:mrow>
  </m:math>
-</inlineequation><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->a</td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> <inlineequation>
+</inlineequation>a</td>
+<td align='right' valign='top'> <inlineequation>
 <alt role='tex'>PR_{maj}</alt>
  <m:math>
  
@@ -1099,7 +1158,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation></td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> <inlineequation>
+<td align='right' valign='top'> <inlineequation>
 <alt role='tex'>PR_{min}</alt>
  <m:math>
  
@@ -1117,113 +1176,126 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
  </m:mrow>
  </m:math>
 </inlineequation></td>
-<td align='center' valign='top' colspan='1'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --><inlineequation>
+<td align='center' valign='top' colspan='1'><inlineequation>
 <alt role='tex'>\Theta</alt>
  <m:math>
  
  <m:mrow><m:mo>&#x398;</m:mo>
  </m:mrow>
  </m:math>
-</inlineequation><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->b</td>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->Ref.</td>
+</inlineequation>b</td>
+<td align='center' valign='top'>Ref.</td>
 </tr>
 <tr>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --><!-- \tableline\tableline -->1 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->33472.5 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-0.1 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->0.4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->53 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->27.4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->2.065 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1.940 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->3.900 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->68.3 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->116.2 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-27.639</td>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1,2</td>
+<td align='center' valign='top'><!-- \tableline\tableline -->
+1 </td>
+<td align='right' valign='top'>33472.5 </td>
+<td align='right' valign='top'>-0.1 </td>
+<td align='right' valign='top'>0.4 </td>
+<td align='right' valign='top'>53 </td>
+<td align='right' valign='top'>27.4 </td>
+<td align='right' valign='top'>2.065 </td>
+<td align='right' valign='top'>1.940 </td>
+<td align='right' valign='top'>3.900 </td>
+<td align='right' valign='top'>68.3 </td>
+<td align='right' valign='top'>116.2 </td>
+<td align='right' valign='top'>-27.639</td>
+<td align='center' valign='top'>1,2</td>
 </tr>
 <tr>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> 2 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->27802.4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-0.3 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-0.2 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->60 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->3.7 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1.628 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1.510 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->2.156 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->6.8 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->7.5 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-26.764</td>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->3</td>
+<td align='center' valign='top'> 2 </td>
+<td align='right' valign='top'>27802.4 </td>
+<td align='right' valign='top'>-0.3 </td>
+<td align='right' valign='top'>-0.2 </td>
+<td align='right' valign='top'>60 </td>
+<td align='right' valign='top'>3.7 </td>
+<td align='right' valign='top'>1.628 </td>
+<td align='right' valign='top'>1.510 </td>
+<td align='right' valign='top'>2.156 </td>
+<td align='right' valign='top'>6.8 </td>
+<td align='right' valign='top'>7.5 </td>
+<td align='right' valign='top'>-26.764</td>
+<td align='center' valign='top'>3</td>
 </tr>
 <tr>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> 3 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->29210.6 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->0.9 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->0.3 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->60 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->3.4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1.622 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1.551 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->2.159 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->6.7 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->7.3 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-40.272</td>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->4</td>
+<td align='center' valign='top'> 3 </td>
+<td align='right' valign='top'>29210.6 </td>
+<td align='right' valign='top'>0.9 </td>
+<td align='right' valign='top'>0.3 </td>
+<td align='right' valign='top'>60 </td>
+<td align='right' valign='top'>3.4 </td>
+<td align='right' valign='top'>1.622 </td>
+<td align='right' valign='top'>1.551 </td>
+<td align='right' valign='top'>2.159 </td>
+<td align='right' valign='top'>6.7 </td>
+<td align='right' valign='top'>7.3 </td>
+<td align='right' valign='top'>-40.272</td>
+<td align='center' valign='top'>4</td>
 </tr>
 <tr>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> 4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->32733.8 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-1.2<!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->c</td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-0.5 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->41 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->54.8 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->2.282 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->2.156 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->4.313 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->117.4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->78.2 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-35.847</td>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->5,6</td>
+<td align='center' valign='top'> 4 </td>
+<td align='right' valign='top'>32733.8 </td>
+<td align='right' valign='top'>-1.2c</td>
+<td align='right' valign='top'>-0.5 </td>
+<td align='right' valign='top'>41 </td>
+<td align='right' valign='top'>54.8 </td>
+<td align='right' valign='top'>2.282 </td>
+<td align='right' valign='top'>2.156 </td>
+<td align='right' valign='top'>4.313 </td>
+<td align='right' valign='top'>117.4 </td>
+<td align='right' valign='top'>78.2 </td>
+<td align='right' valign='top'>-35.847</td>
+<td align='center' valign='top'>5,6</td>
 </tr>
 <tr>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> 5 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> 9607.4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-0.4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-0.4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->60 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1.4 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1.669<!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->c</td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1.574 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->2.343 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->8.0 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->8.9 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-33.417</td>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->7</td>
+<td align='center' valign='top'> 5 </td>
+<td align='right' valign='top'> 9607.4 </td>
+<td align='right' valign='top'>-0.4 </td>
+<td align='right' valign='top'>-0.4 </td>
+<td align='right' valign='top'>60 </td>
+<td align='right' valign='top'>1.4 </td>
+<td align='right' valign='top'>1.669c</td>
+<td align='right' valign='top'>1.574 </td>
+<td align='right' valign='top'>2.343 </td>
+<td align='right' valign='top'>8.0 </td>
+<td align='right' valign='top'>8.9 </td>
+<td align='right' valign='top'>-33.417</td>
+<td align='center' valign='top'>7</td>
 </tr>
 <tr>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> 6 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->31638.6 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->1.6 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->0.1 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->39 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->315.2 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info --> 3.433 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->3.075 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->7.488 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->92.1 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->25.3 </td>
-<td align='right' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->-12.052 </td>
-<td align='center' valign='top'><!-- shouldBeInInfo --><!-- mustBeInInfo --><!-- /info -->8</td>
+<td align='center' valign='top'> 6 </td>
+<td align='right' valign='top'>31638.6 </td>
+<td align='right' valign='top'>1.6 </td>
+<td align='right' valign='top'>0.1 </td>
+<td align='right' valign='top'>39 </td>
+<td align='right' valign='top'>315.2 </td>
+<td align='right' valign='top'> 3.433 </td>
+<td align='right' valign='top'>3.075 </td>
+<td align='right' valign='top'>7.488 </td>
+<td align='right' valign='top'>92.1 </td>
+<td align='right' valign='top'>25.3 </td>
+<td align='right' valign='top'>-12.052 </td>
+<td align='center' valign='top'>8</td>
 </tr>
 </tbody>
-<Table note>a<!-- }{ -->Sample footnote for table&#xA0;<xref linkend="tbl-2" /> that was generated with the LaTeX table environment</Table note>
-<Table note>b<!-- }{ -->Yet another sample footnote for table&#xA0;<xref linkend="tbl-2" /></Table note>
-<Table note>c<!-- }{ -->Another sample footnote for table&#xA0;<xref linkend="tbl-2" /></Table note>
-<TableComments>We can also attach a long-ish paragraph of explanatory material to a table. Use \tablerefs to append a list of references. The following references were from a different table: I've patched them in here to show how they look, but don't take them too seriously—I certainly have not.</TableComments>
-<TableRefs>(1) Barbuy, Spite, & Spite 1985; (2) Bond 1980; (3) Carbon et al. 1987; (4) Hobbs & Duncan 1987; (5) Gilroy et al. 1988: (6) Gratton & Ortolani 1986; (7) Gratton & Sneden 1987; (8) Gratton & Sneden (1988); (9) Gratton & Sneden 1991; (10) Kraft et al. 1982; (11) LCL, or Laird, 1990; (12) Leep & Wallerstein 1981; (13) Luck & Bond 1981; (14) Luck & Bond 1985; (15) Magain 1987; (16) Magain 1989; (17) Peterson 1981; (18) Peterson, Kurucz, & Carney 1990; (19) RMB; (20) Schuster & Nissen 1988; (21) Schuster & Nissen 1989b; (22) Spite et al. 1984; (23) Spite & Spite 1986; (24) Hobbs & Thorburn 1991; (25) Hobbs et al. 1991; (26) Olsen 1983.</TableRefs>
-</table>
-</section>
 
+<Table note>
+a<!-- }{ -->
+Sample footnote for table&#xA0;<xref linkend="tbl-2" /> that was generated with the LaTeX table environment
+</Table note>
+<Table note>
+b<!-- }{ -->
+Yet another sample footnote for table&#xA0;<xref linkend="tbl-2" />
+</Table note>
+<Table note>
+c<!-- }{ -->
+Another sample footnote for table&#xA0;<xref linkend="tbl-2" />
+</Table note>
+<TableComments>
+We can also attach a long-ish paragraph of explanatory material to a table. Use \tablerefs to append a list of references. The following references were from a different table: I've patched them in here to show how they look, but don't take them too seriously—I certainly have not.
+</TableComments>
+<TableRefs>
+(1) Barbuy, Spite, & Spite 1985; (2) Bond 1980; (3) Carbon et al. 1987; (4) Hobbs & Duncan 1987; (5) Gilroy et al. 1988: (6) Gratton & Ortolani 1986; (7) Gratton & Sneden 1987; (8) Gratton & Sneden (1988); (9) Gratton & Sneden 1991; (10) Kraft et al. 1982; (11) LCL, or Laird, 1990; (12) Leep & Wallerstein 1981; (13) Luck & Bond 1981; (14) Luck & Bond 1985; (15) Magain 1987; (16) Magain 1989; (17) Peterson 1981; (18) Peterson, Kurucz, & Carney 1990; (19) RMB; (20) Schuster & Nissen 1988; (21) Schuster & Nissen 1989b; (22) Spite et al. 1984; (23) Spite & Spite 1986; (24) Hobbs & Thorburn 1991; (25) Hobbs et al. 1991; (26) Olsen 1983.
+</TableRefs>
+</table>
 </article>
\ No newline at end of file
diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout
index 74d2ab6..d79cd02 100644
--- a/lib/layouts/aastex.layout
+++ b/lib/layouts/aastex.layout
@@ -179,6 +179,7 @@ Style Affiliation
 	DocBookWrapperTag                 author
 	DocBookWrapperMergeWithPrevious   true
 	DocBookItemTag                    orgname
+	DocBookItemTagType                paragraph
 	DocBookInInfo                     always
 End
 
@@ -207,6 +208,7 @@ Style Altaffilation
 	DocBookWrapperTag                 author
 	DocBookWrapperMergeWithPrevious   true
 	DocBookItemTag                    orgname
+	DocBookItemTagType                paragraph
 	DocBookInInfo                     always
 End
 
@@ -228,6 +230,7 @@ Style Email
 	  Shape		Italic
 	EndFont
 	DocBookTag                        email
+	DocBookTagType                    paragraph
 	DocBookWrapperTag                 author
 	DocBookWrapperMergeWithPrevious   true
 	DocBookInInfo                     always

commit d45d3305559252f7d3e7e39ab54cfe90ab4475e1
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 02:30:24 2020 +0200

    DocBook: adapt SimpleCV for tag types (new-line behaviour).

diff --git a/lib/layouts/simplecv.layout b/lib/layouts/simplecv.layout
index 0a69f1e..1cf6c30 100644
--- a/lib/layouts/simplecv.layout
+++ b/lib/layouts/simplecv.layout
@@ -54,6 +54,7 @@ Style Section
 		IsTocCaption   1
 	EndArgument
 	DocBookTag            title
+	DocBookTagType        paragraph
 	DocBookSectionTag     section
 End
 
@@ -176,6 +177,7 @@ Style Title
 	EndFont
 	HTMLTitle             true
 	DocBookTag            title
+	DocBookTagType        paragraph
 	DocBookInInfo         maybe
 End
 

commit b2ede507bd640fb9cc42c6bfa6e50b3ede858430
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 02:30:04 2020 +0200

    DocBook: fix bibliographies (end of <bibliography> and sections).

diff --git a/autotests/export/docbook/bibliography_precooked.xml b/autotests/export/docbook/bibliography_precooked.xml
index 1f103bc..901abd4 100644
--- a/autotests/export/docbook/bibliography_precooked.xml
+++ b/autotests/export/docbook/bibliography_precooked.xml
@@ -5,11 +5,10 @@
 <title>William Shakespeare</title>
 <section>
 <title>Publications</title>
+</section>
 <bibliography>
 <bibliomixed xml:id='first'>First Folio. </bibliomixed>
 <bibliomixed xml:id='second'>Second Folio. </bibliomixed>
 <bibliomixed xml:id='third'>Third Folio. </bibliomixed>
 </bibliography>
-</section>
-
 </article>
\ No newline at end of file
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index a0ac96a..19bd1d8 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -393,12 +393,9 @@ void makeBibliography(
 
 	// If this is the last paragraph in a bibliography, close the bibliography tag.
 	auto const end = text.paragraphs().end();
-	bool endBibliography = par == end;
-	if (!endBibliography) {
-		auto nextpar = par;
-		++nextpar;
-		endBibliography = par->layout().latextype != LATEX_BIB_ENVIRONMENT;
-	}
+	auto nextpar = par;
+	++nextpar;
+	bool endBibliography = nextpar == end || nextpar->layout().latextype != LATEX_BIB_ENVIRONMENT;
 
 	if (endBibliography) {
 		xs << xml::EndTag("bibliography");
@@ -1124,7 +1121,7 @@ void docbookParagraphs(Text const &text,
 		auto insetsLength = distance(par->insetList().begin(), par->insetList().end());
 		if (insetsLength > 0) {
 			Inset const *firstInset = par->getInset(0);
-			if (firstInset && dynamic_cast<InsetBibtex const *>(firstInset)) {
+			if (firstInset && (firstInset->lyxCode() == BIBITEM_CODE || firstInset->lyxCode() == BIBTEX_CODE)) {
 				while (!headerLevels.empty()) {
 					int level = headerLevels.top().first;
 					docstring tag = from_utf8("</" + headerLevels.top().second + ">");

commit 04e88dcdd8f14bc28497d01862790eae6f4f6696
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 01:14:44 2020 +0200

    DocBook: generate <partintro> when required.

diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml
index ea91d3d..49ec1f4 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -12,7 +12,9 @@
 <para>I am an abstract</para>
 <para>I am also an abstract</para>
 </abstract>
+
 </info>
+<para>I am a standard paragraph. </para>
 <section xml:id="sec.Sec-1">
 <title>I am the first section </title>
 <para>I am the first paragraph of the first section. </para>
diff --git a/autotests/export/docbook/basic_book.xml b/autotests/export/docbook/basic_book.xml
index 18496b9..c6e9078 100644
--- a/autotests/export/docbook/basic_book.xml
+++ b/autotests/export/docbook/basic_book.xml
@@ -17,7 +17,9 @@
 </chapter>
 <part>
 <title>First part</title>
+<partintro>
 <para>Part intro. </para>
+</partintro>
 <chapter>
 <title>First chapter of first part</title>
 <para>Paragraph. </para>
@@ -29,7 +31,9 @@
 </part>
 <part>
 <title>Second part</title>
+<partintro>
 <para>Part 2 intro. </para>
+</partintro>
 <chapter>
 <title>First chapter of second part</title>
 <para>Paragraph. </para>
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 3e37f90..a0ac96a 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -821,7 +821,7 @@ bool hasOnlyNotes(Paragraph const & par)
 	for (int i = 0; i < par.size(); ++i)
 		// If you find something that is not an inset (like actual text) or an inset that is not a note,
 		// return false.
-		if (!par.isInset(i) || !dynamic_cast<InsetNote *>(par.insetList().get(i)))
+		if (!par.isInset(i) || par.getInset(i)->lyxCode() != NOTE_CODE)
 			return false;
 	return true;
 }
@@ -851,7 +851,7 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const &paragraphs,
 	for (; cpit < epit; ++cpit) {
 		// Skip paragraphs that don't generate anything in DocBook.
 		Paragraph const & par = paragraphs[cpit];
-		if (par.empty() || par.emptyTag() || hasOnlyNotes(par))
+		if (hasOnlyNotes(par))
 			continue;
 
 		// There should never be any section here. (Just a sanity check: if this fails, this function could end up
@@ -869,14 +869,14 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const &paragraphs,
 		}
 
 		// Based on layout information, store this paragraph in one set: should be in <info>, must be,
-		// or abstract ().
+		// or abstract (either because of layout or of position).
 		Layout const &style = par.layout();
 
 		if (style.docbookininfo() == "always")
 			mustBeInInfo.emplace(cpit);
 		else if (style.docbookininfo() == "maybe")
 			shouldBeInInfo.emplace(cpit);
-		else if (!hasAbstractLayout)
+		else if (documentHasSections && !hasAbstractLayout)
 			abstractNoLayout.emplace(cpit);
 		else // This should definitely not be in <info>.
 			break;
@@ -993,17 +993,17 @@ void docbookSimpleAllParagraphs(
 {
 	// Handle the given text, supposing it has no sections (i.e. a "simple" text). The input may vary in length
 	// between a single paragraph to a whole document.
+	pit_type const bpit = runparams.par_begin;
+	pit_type const epit = runparams.par_end;
+	ParagraphList const &paragraphs = text.paragraphs();
 
 	// First, the <info> tag.
-	ParagraphList const &paragraphs = text.paragraphs();
-	pit_type bpit = runparams.par_begin;
-	pit_type const epit = runparams.par_end;
 	DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit, false);
 	outputDocBookInfo(text, buf, xs, runparams, paragraphs, info);
 
 	// Then, the content. It starts where the <info> ends.
-	auto par = text.paragraphs().iterator_at(info.epit);
-	auto end = text.paragraphs().iterator_at(epit);
+	auto par = paragraphs.iterator_at(info.epit);
+	auto end = paragraphs.iterator_at(epit);
 	while (par != end) {
 		if (!hasOnlyNotes(*par))
 			par = makeAny(text, buf, xs, runparams, par);
@@ -1040,7 +1040,7 @@ void docbookParagraphs(Text const &text,
 	tie(documentHasSections, eppit) = hasDocumentSectioning(paragraphs, bpit, epit);
 
 	// Deal with "simple" documents, i.e. those without sections.
-	if (!documentHasSections){
+	if (!documentHasSections) {
 		docbookSimpleAllParagraphs(text, buf, xs, runparams);
 		return;
 	}
@@ -1048,7 +1048,7 @@ void docbookParagraphs(Text const &text,
 	// Output the first <info> tag (or just the title).
 	DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, eppit, true);
 	outputDocBookInfo(text, buf, xs, runparams, paragraphs, info);
-	bpit = eppit;
+	bpit = info.epit;
 
 	// Then, iterate through the paragraphs of this document.
 	bool currentlyInAppendix = false;
@@ -1141,6 +1141,29 @@ void docbookParagraphs(Text const &text,
 
 		// Generate this paragraph.
 		par = makeAny(text, buf, xs, ourparams, par);
+
+		// Some special sections may require abstracts (mostly parts, in books).
+		// TODO: docbookforceabstracttag is a bit contrived here, but it does the job. Having another field just for this would be cleaner, but that's just for <part> and <partintro>, so it's probably not worth the effort.
+		if (isLayoutSectioning(style) && style.docbookforceabstracttag() != "NONE") {
+			// This abstract may be found between the next paragraph and the next title.
+			pit_type cpit = std::distance(text.paragraphs().begin(), par);
+			pit_type ppit = std::get<1>(hasDocumentSectioning(paragraphs, cpit, epit));
+
+			// Generate this abstract (this code corresponds to parts of outputDocBookInfo).
+			DocBookInfoTag secInfo = getParagraphsWithInfo(paragraphs, cpit, ppit, true);
+
+			if (!secInfo.abstract.empty()) {
+				xs << xml::StartTag(style.docbookforceabstracttag());
+				xs << xml::CR();
+				for (auto const &p : secInfo.abstract)
+					makeAny(text, buf, xs, runparams, paragraphs.iterator_at(p));
+				xs << xml::EndTag(style.docbookforceabstracttag());
+				xs << xml::CR();
+			}
+
+			// Skip all the text that just has been generated.
+			par = paragraphs.iterator_at(ppit);
+		}
 	}
 
 	// If need be, close <section>s, but only at the end of the document (otherwise, dealt with at the beginning

commit a0ba094bcd6095abd09dda50d01713a9bf70a562
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 00:58:50 2020 +0200

    DocBook: streamline code to handle sections.

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 38bcf05..3e37f90 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -1071,18 +1071,18 @@ void docbookParagraphs(Text const &text,
 		if (isLayoutSectioning(style)) {
 			int level = style.toclevel;
 
-			// Need to close a previous section if it has the same level or a higher one (close <section> if opening a <h2>
-			// after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
+			// Need to close a previous section if it has the same level or a higher one (close <section> if opening a
+			// <h2> after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
 			//   - current: h2; back: h1; do not close any <section>
 			//   - current: h1; back: h2; close two <section> (first the <h2>, then the <h1>, so a new <h1> can come)
 			while (!headerLevels.empty() && level <= headerLevels.top().first) {
+				// Output the tag only if it corresponds to a legit section.
 				int stackLevel = headerLevels.top().first;
-				docstring stackTag = from_utf8("</" + headerLevels.top().second + ">");
+				if (stackLevel != Layout::NOT_IN_TOC) {
+					xs << xml::EndTag(headerLevels.top().second);
+					xs << xml::CR();
+				}
 				headerLevels.pop();
-
-				// Output the tag only if it corresponds to a legit section.
-				if (stackLevel != Layout::NOT_IN_TOC)
-					xs << XMLStream::ESCAPE_NONE << stackTag << xml::CR();
 			}
 
 			// Open the new section: first push it onto the stack, then output it in DocBook.
@@ -1111,11 +1111,10 @@ void docbookParagraphs(Text const &text,
 				}
 
 				// Write the open tag for this section.
-				docstring tag = from_utf8("<" + sectionTag);
+				docstring attrs;
 				if (!id.empty())
-					tag += from_utf8(" ") + id;
-				tag += from_utf8(">");
-				xs << XMLStream::ESCAPE_NONE << tag;
+					attrs = id;
+				xs << xml::StartTag(sectionTag, attrs);
 				xs << xml::CR();
 			}
 		}

commit e54ea8bbc327c296d21554df197a1f652ac81e1f
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Aug 30 00:35:47 2020 +0200

    DocBook: streamline code to handle abstracts.

diff --git a/autotests/export/docbook/basic_book.xml b/autotests/export/docbook/basic_book.xml
index c94d2fa..18496b9 100644
--- a/autotests/export/docbook/basic_book.xml
+++ b/autotests/export/docbook/basic_book.xml
@@ -1,12 +1,14 @@
 <?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 -->
-<book 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">
-
-<info><title>Book title</title>
-<author><personname>Book author</personname></author>
-
-<abstract><para>Book abstract in info. </para>
+<book 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">
+<info>
+<title>Book title</title>
+<author>
+<personname>Book author</personname>
+</author>
+<abstract>
+<para>Book abstract in info. </para>
 </abstract>
 </info>
 <chapter>
@@ -15,9 +17,7 @@
 </chapter>
 <part>
 <title>First part</title>
-
-<partintro><para>Part intro. </para>
-</partintro>
+<para>Part intro. </para>
 <chapter>
 <title>First chapter of first part</title>
 <para>Paragraph. </para>
@@ -29,9 +29,7 @@
 </part>
 <part>
 <title>Second part</title>
-
-<partintro><para>Part 2 intro. </para>
-</partintro>
+<para>Part 2 intro. </para>
 <chapter>
 <title>First chapter of second part</title>
 <para>Paragraph. </para>
@@ -41,5 +39,4 @@
 <para>Paragraph. </para>
 </chapter>
 </part>
-
 </book>
\ No newline at end of file
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index e609f39..38bcf05 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -773,21 +773,28 @@ ParagraphList::const_iterator makeAny(Text const &text,
 }
 
 
+bool isLayoutSectioning(Layout const & lay)
+{
+	return lay.category() == from_utf8("Sectioning");
+}
+
+
 using DocBookDocumentSectioning = tuple<bool, pit_type>;
 
 
 struct DocBookInfoTag
 {
 	const set<pit_type> shouldBeInInfo;
-	const set<pit_type> mustBeInInfo;
+	const set<pit_type> mustBeInInfo; // With the notable exception of the abstract!
 	const set<pit_type> abstract;
+	const bool abstractLayout;
 	pit_type bpit;
 	pit_type epit;
 
 	DocBookInfoTag(const set<pit_type> & shouldBeInInfo, const set<pit_type> & mustBeInInfo,
-				   const set<pit_type> & abstract, pit_type bpit, pit_type epit) :
+				   const set<pit_type> & abstract, bool abstractLayout, pit_type bpit, pit_type epit) :
 				   shouldBeInInfo(shouldBeInInfo), mustBeInInfo(mustBeInInfo), abstract(abstract),
-				   bpit(bpit), epit(epit) {}
+				   abstractLayout(abstractLayout), bpit(bpit), epit(epit) {}
 };
 
 
@@ -796,7 +803,7 @@ DocBookDocumentSectioning hasDocumentSectioning(ParagraphList const &paragraphs,
 
 	while (bpit < epit) {
 		Layout const &style = paragraphs[bpit].layout();
-		documentHasSections |= style.category() == from_utf8("Sectioning");
+		documentHasSections |= isLayoutSectioning(style);
 
 		if (documentHasSections)
 			break;
@@ -820,10 +827,14 @@ bool hasOnlyNotes(Paragraph const & par)
 }
 
 
-DocBookInfoTag getParagraphsWithInfo(ParagraphList const &paragraphs, pit_type bpit, pit_type const epit) {
+DocBookInfoTag getParagraphsWithInfo(ParagraphList const &paragraphs,
+									 pit_type bpit, pit_type const epit,
+									 // Typically, bpit is the beginning of the document and epit the end *or* the first section.
+									 bool documentHasSections) {
 	set<pit_type> shouldBeInInfo;
 	set<pit_type> mustBeInInfo;
-	set<pit_type> abstract;
+	set<pit_type> abstractWithLayout;
+	set<pit_type> abstractNoLayout;
 
 	// Find the first non empty paragraph by mutating bpit.
 	while (bpit < epit) {
@@ -834,78 +845,48 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const &paragraphs, pit_type b
 			break;
 	}
 
-	// Find the last info-like paragraph.
-	pit_type cpit = bpit;
+	// Traverse everything that might belong to <info>.
 	bool hasAbstractLayout = false;
-	while (cpit < epit) {
-		// Skip paragraphs only containing one note.
+	pit_type cpit = bpit;
+	for (; cpit < epit; ++cpit) {
+		// Skip paragraphs that don't generate anything in DocBook.
 		Paragraph const & par = paragraphs[cpit];
-		if (hasOnlyNotes(par)) {
-			cpit += 1;
+		if (par.empty() || par.emptyTag() || hasOnlyNotes(par))
 			continue;
+
+		// There should never be any section here. (Just a sanity check: if this fails, this function could end up
+		// processing the whole document.)
+		if (isLayoutSectioning(par.layout())) {
+			LYXERR0("Assertion failed: section found in potential <info> paragraphs.");
+			break;
 		}
 
-		if (par.layout().docbookabstract())
+		// If this is marked as an abstract by the layout, put it in the right set.
+		if (par.layout().docbookabstract()) {
 			hasAbstractLayout = true;
+			abstractWithLayout.emplace(cpit);
+			continue;
+		}
 
-		// Based on layout information, store this paragraph in one set: should be in <info>, must be.
+		// Based on layout information, store this paragraph in one set: should be in <info>, must be,
+		// or abstract ().
 		Layout const &style = par.layout();
 
-		if (style.docbookininfo() == "always") {
+		if (style.docbookininfo() == "always")
 			mustBeInInfo.emplace(cpit);
-		} else if (style.docbookininfo() == "maybe") {
+		else if (style.docbookininfo() == "maybe")
 			shouldBeInInfo.emplace(cpit);
-		} else {
-			// Hypothesis: the <info> parts should be grouped together near the beginning bpit.
-			// There may be notes in between, but nothing else.
+		else if (!hasAbstractLayout)
+			abstractNoLayout.emplace(cpit);
+		else // This should definitely not be in <info>.
 			break;
-		}
-		cpit += 1;
 	}
-	// Now, cpit points to the last paragraph that has things that could go in <info>.
+	// Now, cpit points to the first paragraph that no more has things that could go in <info>.
 	// bpit is the beginning of the <info> part.
 
-	// Go once again through the list of paragraphs to find the abstract. If there is an abstract
-	// layout, only consider it. Otherwise, an abstract is just a sequence of paragraphs with text.
-	if (hasAbstractLayout) {
-		pit_type pit = bpit;
-		while (pit < cpit) { // Don't overshoot the <info> part.
-			if (paragraphs[pit].layout().docbookabstract())
-				abstract.emplace(pit);
-			pit++;
-		}
-	} else {
-		pit_type lastAbstract = epit + 1; // A nonsensical value.
-		docstring lastAbstractLayout;
-
-		pit_type pit = bpit;
-		while (pit < cpit) { // Don't overshoot the <info> part.
-			const Paragraph & par = paragraphs.at(pit);
-			if (!par.insetList().empty()) {
-				for (const auto &i : par.insetList()) {
-					if (i.inset->getText(0) != nullptr) {
-						if (lastAbstract == epit + 1) {
-							// First paragraph that matches the heuristic definition of abstract.
-							lastAbstract = pit;
-							lastAbstractLayout = par.layout().name();
-						} else if (pit > lastAbstract + 1 || par.layout().name() != lastAbstractLayout) {
-							// This is either too far from the last abstract paragraph or doesn't
-							// have the right layout name, BUT there has already been an abstract
-							// in this document: done with detecting the abstract.
-							goto done; // Easier to get out of two nested loops.
-						}
-
-						abstract.emplace(pit);
-						break;
-					}
-				}
-			}
-			pit++;
-		}
-	}
-
-	done:
-	return DocBookInfoTag(shouldBeInInfo, mustBeInInfo, abstract, bpit, cpit);
+	return DocBookInfoTag(shouldBeInInfo, mustBeInInfo,
+					      hasAbstractLayout ? abstractWithLayout : abstractNoLayout,
+					      hasAbstractLayout, bpit, cpit);
 }
 
 } // end anonymous namespace
@@ -940,17 +921,9 @@ void outputDocBookInfo(
 	if (hasAbstract) {
 		// Generate the abstract XML into a string before further checks.
 		odocstringstream os2;
-		{
-			XMLStream xs2(os2);
-			auto bpit = *std::min_element(info.abstract.begin(), info.abstract.end());
-			auto epit = 1 + *std::max_element(info.abstract.begin(), info.abstract.end());
-			// info.abstract is inclusive, epit is exclusive, hence +1 for looping.
-
-			while (bpit < epit) {
-				makeAny(text, buf, xs2, runparams, paragraphs.iterator_at(bpit));
-				bpit += 1;
-			}
-		}
+		XMLStream xs2(os2);
+		for (auto const & p : info.abstract)
+			makeAny(text, buf, xs2, runparams, paragraphs.iterator_at(p));
 
 		// Actually output the abstract if there is something to do. Don't count line feeds or spaces in this,
 		// even though they must be properly output if there is some abstract.
@@ -974,27 +947,33 @@ void outputDocBookInfo(
 	}
 
 	// Output the elements that should go in <info>, before and after the abstract.
-	for (auto pit : info.shouldBeInInfo) { // Typically, the title: these elements are so important and ubiquitous
+	for (auto pit : info.shouldBeInInfo) // Typically, the title: these elements are so important and ubiquitous
 		// that mandating a wrapper like <info> would repel users. Thus, generate them first.
 		makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit));
-	}
-	for (auto pit : info.mustBeInInfo) {
+	for (auto pit : info.mustBeInInfo)
 		if (info.abstract.find(pit) == info.abstract.end()) // The abstract must be in info, but is dealt with after.
 			makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit));
-	}
 
 	// Always output the abstract as the last item of the <info>, as it requires special treatment (especially if
 	// it contains several paragraphs that are empty).
 	if (hasAbstract) {
-//		string tag = paragraphs[*info.abstract.begin()].layout().docbookforceabstracttag();
-//		if (tag == "NONE")
-//			tag = "abstract";
-//
-//		xs << xml::StartTag(tag);
-//		xs << xml::CR();
-		xs << XMLStream::ESCAPE_NONE << abstract;
-//		xs << xml::EndTag(tag);
-//		xs << xml::CR();
+		if (info.abstractLayout) {
+			xs << XMLStream::ESCAPE_NONE << abstract;
+			xs << xml::CR();
+		} else {
+			string tag = paragraphs[*info.abstract.begin()].layout().docbookforceabstracttag();
+			if (tag == "NONE")
+				tag = "abstract";
+
+			if (!xs.isLastTagCR())
+				xs << xml::CR();
+
+			xs << xml::StartTag(tag);
+			xs << xml::CR();
+			xs << XMLStream::ESCAPE_NONE << abstract;
+			xs << xml::EndTag(tag);
+			xs << xml::CR();
+		}
 	}
 
 	// End the <info> tag if it was started.
@@ -1006,23 +985,6 @@ void outputDocBookInfo(
 }
 
 
-void docbookFirstParagraphs(
-		Text const &text,
-		Buffer const &buf,
-		XMLStream &xs,
-		OutputParams const &runparams,
-		pit_type epit)
-{
-	// Handle the beginning of the document, supposing it has sections.
-	// Major role: output the first <info> tag.
-
-	ParagraphList const &paragraphs = text.paragraphs();
-	pit_type bpit = runparams.par_begin;
-	DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit);
-	outputDocBookInfo(text, buf, xs, runparams, paragraphs, info);
-}
-
-
 void docbookSimpleAllParagraphs(
 		Text const & text,
 		Buffer const & buf,
@@ -1036,7 +998,7 @@ void docbookSimpleAllParagraphs(
 	ParagraphList const &paragraphs = text.paragraphs();
 	pit_type bpit = runparams.par_begin;
 	pit_type const epit = runparams.par_end;
-	DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit);
+	DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit, false);
 	outputDocBookInfo(text, buf, xs, runparams, paragraphs, info);
 
 	// Then, the content. It starts where the <info> ends.
@@ -1071,20 +1033,24 @@ void docbookParagraphs(Text const &text,
 	std::stack<std::pair<int, string>> headerLevels; // Used to determine when to open/close sections: store the depth
 	// of the section and the tag that was used to open it.
 
-	// Detect whether the document contains sections. If there are no sections, there can be no automatically
-	// discovered abstract.
+	// Detect whether the document contains sections. If there are no sections, treatment is largely simplified.
+	// In particular, there can't be an abstract, unless it is manually marked.
 	bool documentHasSections;
 	pit_type eppit;
 	tie(documentHasSections, eppit) = hasDocumentSectioning(paragraphs, bpit, epit);
 
-	if (documentHasSections) {
-		docbookFirstParagraphs(text, buf, xs, runparams, eppit);
-		bpit = eppit;
-	} else {
+	// Deal with "simple" documents, i.e. those without sections.
+	if (!documentHasSections){
 		docbookSimpleAllParagraphs(text, buf, xs, runparams);
 		return;
 	}
 
+	// Output the first <info> tag (or just the title).
+	DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, eppit, true);
+	outputDocBookInfo(text, buf, xs, runparams, paragraphs, info);
+	bpit = eppit;
+
+	// Then, iterate through the paragraphs of this document.
 	bool currentlyInAppendix = false;
 
 	auto par = text.paragraphs().iterator_at(bpit);
@@ -1102,8 +1068,7 @@ void docbookParagraphs(Text const &text,
 		Layout const &style = par->layout();
 
 		// Think about adding <section> and/or </section>s.
-		const bool isLayoutSectioning = style.category() == from_utf8("Sectioning");
-		if (isLayoutSectioning) {
+		if (isLayoutSectioning(style)) {
 			int level = style.toclevel;
 
 			// Need to close a previous section if it has the same level or a higher one (close <section> if opening a <h2>

commit fc61bab5d4185e6f83652d6c96b8e504e1531976
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Aug 29 23:41:28 2020 +0200

    DocBook: fix handling of index end-of-range.

diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml
index a4dc276..ea91d3d 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -205,9 +205,9 @@ I am a second line of code.
 <para>Then several terms for the first index: <indexterm type="idx"><primary>Term</primary><secondary>to</secondary><tertiary>index</tertiary></indexterm>. </para>
 <para>With a see: <indexterm type="idx"><primary>Term</primary><see>index</see></indexterm>. With a see also: <indexterm type="idx"><primary>Term</primary><seealso>index</seealso></indexterm>. </para>
 <para>Several terms with a see: <indexterm type="idx"><primary>Term</primary><secondary>to</secondary><tertiary>index</tertiary><see>index</see></indexterm>. Several terms with a see also: <indexterm type="idx"><primary>Term</primary><secondary>to</secondary><tertiary>index</tertiary><seealso>index</seealso></indexterm>. </para>
-<para>A start of range: <indexterm type="idx" class="startofrange" xml:id="Term-to-index"><primary>Term to index</primary></indexterm>. The corresponding end of range: <indexterm type="idx" class="endofrange" startref="Term-to-index"><primary>Term to index</primary></indexterm>.</para>
-<para>Several terms with a start of range: <indexterm type="idx" class="startofrange" xml:id="Term.to.index"><primary>Term</primary><secondary>to</secondary><tertiary>index</tertiary></indexterm>. The corresponding end of range: <indexterm type="idx" class="endofrange" startref="Term.to.index"><primary>Term</primary><secondary>to</secondary><tertiary>index</tertiary></indexterm>.</para>
-<para>These terms already appeared before! Start of range: <indexterm type="idx" class="startofrange" xml:id="Term.to.index-0"><primary>Term</primary><secondary>to</secondary><tertiary>index</tertiary></indexterm>. The corresponding end of range: <indexterm type="idx" class="endofrange" startref="Term.to.index-0"><primary>Term</primary><secondary>to</secondary><tertiary>index</tertiary></indexterm>.</para>
+<para>A start of range: <indexterm type="idx" class="startofrange" xml:id="Term-to-index"><primary>Term to index</primary></indexterm>. The corresponding end of range: <indexterm class="endofrange" startref="Term-to-index" />.</para>
+<para>Several terms with a start of range: <indexterm type="idx" class="startofrange" xml:id="Term.to.index"><primary>Term</primary><secondary>to</secondary><tertiary>index</tertiary></indexterm>. The corresponding end of range: <indexterm class="endofrange" startref="Term.to.index" />.</para>
+<para>These terms already appeared before! Start of range: <indexterm type="idx" class="startofrange" xml:id="Term.to.index-0"><primary>Term</primary><secondary>to</secondary><tertiary>index</tertiary></indexterm>. The corresponding end of range: <indexterm class="endofrange" startref="Term.to.index-0" />.</para>
 </section>
 <section>
 <title>I am the eight section and I deal with star sections</title>
diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index 987c138..149ef65 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -287,14 +287,17 @@ void InsetIndex::docbook(XMLStream & xs, OutputParams const & runparams) const
 		// Hence the thread-local storage, as the numbers must strictly be unique, and thus cannot be shared across
 		// a paragraph (making the solution used for HTML worthless). This solution is very similar to the one used in
 		// xml::cleanID.
-		docstring attrs = indexType;
-		if (hasStartRange || hasEndRange) {
+		// indexType can only be used for singular and startofrange types!
+		docstring attrs;
+		if (!hasStartRange && !hasEndRange) {
+			attrs = indexType;
+		} else {
 			// Append an ID if uniqueness is not guaranteed across the document.
 			static QThreadStorage<set<docstring>> tKnownTermLists;
 			static QThreadStorage<int> tID;
 
-			set<docstring> & knownTermLists = tKnownTermLists.localData();
-			int & ID = tID.localData();
+			set<docstring> &knownTermLists = tKnownTermLists.localData();
+			int &ID = tID.localData();
 
 			if (!tID.hasLocalData()) {
 				tID.localData() = 0;
@@ -319,47 +322,51 @@ void InsetIndex::docbook(XMLStream & xs, OutputParams const & runparams) const
 			// Generate the attributes.
 			docstring id = xml::cleanID(newIndexTerms);
 			if (hasStartRange) {
-				attrs += " class=\"startofrange\" xml:id=\"" + id + "\"";
+				attrs = indexType + " class=\"startofrange\" xml:id=\"" + id + "\"";
 			} else {
-				attrs += " class=\"endofrange\" startref=\"" + id + "\"";
+				attrs = " class=\"endofrange\" startref=\"" + id + "\"";
 			}
 		}
 
 		// Handle the index terms (including the specific index for this entry).
-		xs << xml::StartTag("indexterm", attrs);
-		if (terms.size() > 0) { // hasEndRange has no content.
-			xs << xml::StartTag("primary");
-			xs << terms[0];
-			xs << xml::EndTag("primary");
-		}
-		if (terms.size() > 1) {
-			xs << xml::StartTag("secondary");
-			xs << terms[1];
-			xs << xml::EndTag("secondary");
-		}
-		if (terms.size() > 2) {
-			xs << xml::StartTag("tertiary");
-			xs << terms[2];
-			xs << xml::EndTag("tertiary");
-		}
+		if (hasEndRange) {
+			xs << xml::CompTag("indexterm", attrs);
+		} else {
+			xs << xml::StartTag("indexterm", attrs);
+			if (!terms.empty()) { // hasEndRange has no content.
+				xs << xml::StartTag("primary");
+				xs << terms[0];
+				xs << xml::EndTag("primary");
+			}
+			if (terms.size() > 1) {
+				xs << xml::StartTag("secondary");
+				xs << terms[1];
+				xs << xml::EndTag("secondary");
+			}
+			if (terms.size() > 2) {
+				xs << xml::StartTag("tertiary");
+				xs << terms[2];
+				xs << xml::EndTag("tertiary");
+			}
 
-		// Handle see and see also.
-		if (!see.empty()) {
-			xs << xml::StartTag("see");
-			xs << see;
-			xs << xml::EndTag("see");
-		}
+			// Handle see and see also.
+			if (!see.empty()) {
+				xs << xml::StartTag("see");
+				xs << see;
+				xs << xml::EndTag("see");
+			}
 
-		if (!seeAlsoes.empty()) {
-			for (auto & entry : seeAlsoes) {
-				xs << xml::StartTag("seealso");
-				xs << entry;
-				xs << xml::EndTag("seealso");
+			if (!seeAlsoes.empty()) {
+				for (auto &entry : seeAlsoes) {
+					xs << xml::StartTag("seealso");
+					xs << entry;
+					xs << xml::EndTag("seealso");
+				}
 			}
-		}
 
-		// Close the entry.
-		xs << xml::EndTag("indexterm");
+			// Close the entry.
+			xs << xml::EndTag("indexterm");
+		}
 	}
 }
 
diff --git a/src/xml.cpp b/src/xml.cpp
index 0daa9d8..557bb01 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -140,11 +140,11 @@ docstring EndTag::writeEndTag() const
 
 docstring CompTag::writeTag() const
 {
-	docstring output = '<' + from_utf8(tag_);
+	docstring output = '<' + tag_;
 	if (!attr_.empty()) {
 		// Erase the beginning of the attributes if it contains space characters: this function deals with that
 		// automatically.
-		docstring attributes = escapeString(from_utf8(attr_), XMLStream::ESCAPE_NONE);
+		docstring attributes = escapeString(attr_, XMLStream::ESCAPE_NONE);
 		attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(),
                                                           [](int c) {return !std::isspace(c);}));
 		if (!attributes.empty()) {
diff --git a/src/xml.h b/src/xml.h
index 56e5d81..52eeb22 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -240,16 +240,19 @@ struct CompTag
 {
 	///
 	explicit CompTag(std::string const & tag)
-			: tag_(tag) {}
+			: tag_(from_utf8(tag)) {}
 	///
 	explicit CompTag(std::string const & tag, std::string const & attr)
-			: tag_(tag), attr_(attr) {}
+			: tag_(from_utf8(tag)), attr_(from_utf8(attr)) {}
+	///
+	explicit CompTag(std::string const & tag, docstring const & attr)
+			: tag_(from_utf8(tag)), attr_(attr) {}
 	/// <tag_ attr_ />
 	docstring writeTag() const;
 	///
-	std::string tag_;
+	docstring tag_;
 	///
-	std::string attr_;
+	docstring attr_;
 };
 
 

commit b75de4f79b53b2060930cffcb7ecaa8e78ea0b81
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Aug 29 22:58:23 2020 +0200

    DocBook: fix float tags (was unduly overridden).
    
    The output was not valid for floats without title.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d3aa192..9085355 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,11 @@
 
 cmake_minimum_required(VERSION 3.1.0)
 
+set(CMAKE_CXX_STANDARD 20)
+set(GNUWIN32_DIR D:/LyX/lyx-unstable/lyx-windows-deps-msvc2017)
+set(LYX_USE_QT "QT5")
+set(LYX_REQUIRE_SPELLCHECK true)
+
 set(LYX_PROJECT LyX)
 
 # Instruct cmake to not use gnu extensions,
diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml
index 430611e..a4dc276 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -164,7 +164,7 @@ I am a second line of code.
 </tr>
 </tbody>
 </table>
-<table>
+<informaltable>
 <tbody>
 <tr>
 <td align='center' valign='top'>Table that has no caption 1</td>
@@ -182,7 +182,7 @@ I am a second line of code.
 <td align='center' valign='top'>Col 3, row 2</td>
 </tr>
 </tbody>
-</table>
+</informaltable>
 
 <para>Then, one figure: </para>
 <figure>
diff --git a/lib/layouts/stdfloats.inc b/lib/layouts/stdfloats.inc
index cd6614a..044fcb2 100644
--- a/lib/layouts/stdfloats.inc
+++ b/lib/layouts/stdfloats.inc
@@ -20,7 +20,6 @@ Float
 	UsesFloatPkg          false
 	ListCommand           listoftables
 	RefPrefix             tab
-	DocBookTag            table
 End
 
 
@@ -36,7 +35,6 @@ Float
 	UsesFloatPkg          false
 	ListCommand           listoffigures
 	RefPrefix             fig
-	DocBookTag            figure
 End
 
 
@@ -51,7 +49,6 @@ Float
 	IsPredefined          false
 	UsesFloatPkg          true
 	RefPrefix             alg
-	DocBookTag            figure # TODO: No DocBook tag really corresponds...
 End
 
 
diff --git a/src/Floating.cpp b/src/Floating.cpp
index d44afc3..19fbf5f 100644
--- a/src/Floating.cpp
+++ b/src/Floating.cpp
@@ -40,8 +40,7 @@ Floating::Floating(string const & type, string const & placement,
 	  usesfloatpkg_(usesfloat), ispredefined_(ispredefined),
 	  allowswide_(allowswide), allowssideways_(allowssideways),
 	  html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle),
-	  docbook_tag_(docbookTag), docbook_attr_(docbookAttr),
-	  docbook_tag_type_(docbookTagType)
+	  docbook_attr_(docbookAttr), docbook_tag_type_(docbookTagType)
 {}
 
 
@@ -89,21 +88,17 @@ string const & Floating::docbookAttr() const
 }
 
 
-string const & Floating::docbookTag(bool hasTitle) const
+string Floating::docbookTag(bool hasTitle) const
 {
-	if (docbook_tag_.empty()) {
-		docbook_tag_ = "";
-		if (floattype_ == "figure") {
-			docbook_tag_ = hasTitle ? "figure" : "informalfigure";
-		} else if (floattype_ == "table") {
-			docbook_tag_ = hasTitle ? "table" : "informaltable";
-		} else if (floattype_ == "algorithm") {
-			// TODO: no good translation for now! Figures are the closest match, as they can contain text.
-			// Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
-			docbook_tag_ = "figure";
-		}
+	if (floattype_ == "figure") {
+		return hasTitle ? "figure" : "informalfigure";
+	} else if (floattype_ == "table") {
+		return hasTitle ? "table" : "informaltable";
+	} else if (floattype_ == "algorithm") {
+		// TODO: no good translation for now! Figures are the closest match, as they can contain text.
+		// Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
+		return "figure";
 	}
-	return docbook_tag_;
 }
 
 
diff --git a/src/Floating.h b/src/Floating.h
index 5cfea08..977958b 100644
--- a/src/Floating.h
+++ b/src/Floating.h
@@ -81,7 +81,7 @@ public:
 	/// tag type, defaults to "div"
 	std::string const & htmlTag() const;
 	///
-	std::string const & docbookTag(bool hasTitle = false) const;
+	std::string docbookTag(bool hasTitle = false) const;
 	///
 	std::string const & docbookAttr() const;
 	///
@@ -129,8 +129,8 @@ private:
 	mutable std::string defaultcssclass_;
 	///
 	docstring html_style_;
-	/// DocBook tag
-	mutable std::string docbook_tag_;
+	// There is no way to override the DocBook tag based on the layouts: half of it is determined by whether the float
+	// has a title or not, an information that is not available in the layouts.
 	/// attribute (mostly, role)
 	mutable std::string docbook_caption_;
 	/// caption tag (mostly, either caption or title)
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index 24e06b5..86bcf9d 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -654,7 +654,7 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
 
 	xs << xml::StartTag(ftype.docbookTag(caption != nullptr), attr);
 	xs << xml::CR();
-	if (caption != nullptr) {
+	if (caption) {
 		xs << xml::StartTag(titleTag);
 		caption->getCaptionAsDocBook(xs, rpNoLabel);
 		xs << xml::EndTag(titleTag);
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 5847121..af30e8e 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2429,7 +2429,7 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
 	}
 
 	// DocBook also has <equation>, but it comes with a title.
-	// TODO: recognise \tag from amsmath?
+	// TODO: recognise \tag from amsmath? This would allow having <equation> with a proper title.
 
 	docstring attr;
 	for (row_type i = 0; i < nrows(); ++i) {

commit 003378708a8caec3de70e25d6ab3d61f432a6dbe
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Aug 29 19:05:59 2020 +0200

    DocBook: improve equation formatting (new lines for block equations).

diff --git a/autotests/export/docbook/basic.lyx b/autotests/export/docbook/basic.lyx
index 1735dc4..fa98d65 100644
--- a/autotests/export/docbook/basic.lyx
+++ b/autotests/export/docbook/basic.lyx
@@ -185,7 +185,7 @@ noprefix "false"
 
 \begin_layout Standard
 Also, a formula with an user-defined macro that outputs well in LaTeX but
- cannot in MathML (hence replaced by picture): 
+ cannot in MathML: 
 \begin_inset Formula $\testmacro$
 \end_inset
 
diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml
index 7980289..430611e 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -30,7 +30,7 @@
 </inlineequation>. </para>
 </blockquote>
 <para>Now, we're outside quotes.</para>
-<para><informalequation>
+<informalequation>
 <alt role='tex'>Formula!</alt>
  <m:math>
  
@@ -39,7 +39,8 @@
   </m:mrow>
  </m:mrow>
  </m:math>
-</informalequation><informalequation xml:id="eq.EQ.">
+</informalequation>
+<informalequation xml:id="eq.EQ.">
 <alt role='tex'>\text{I am a formula with a ref.}\label{eq:EQ.}</alt>
  <m:math>
  
@@ -50,9 +51,9 @@
   </m:mstyle>
  </m:mrow>
  </m:math>
-</informalequation></para>
+</informalequation>
 <para>See <xref linkend="sec.Sec-2kqgsdiflhqsdlifgjuzer-povtuizmvnuer-t-vmsrmfli--uh--a--rtpfuo----rtpc.m-ca-rgifzapeu-tvgz" />.</para>
-<para>Also, a formula with an user-defined macro that outputs well in LaTeX but cannot in MathML (hence replaced by picture): <inlineequation>
+<para>Also, a formula with an user-defined macro that outputs well in LaTeX but cannot in MathML: <inlineequation>
 <alt role='tex'>\testmacro</alt>
 <mathphrase>MathML export failed. Please report this as a bug.</mathphrase>
 </inlineequation>. </para>
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index e87ef88..aad1ccf 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3349,7 +3349,8 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
 
 	std::vector<docstring> generatedParagraphs;
 	odocstringstream os;
-	auto * xs = new XMLStream(os);
+	auto * xs = new XMLStream(os); // XMLStream has no copy constructor: to create a new object, the only solution
+	// is to hold a pointer to the XMLStream (xs = XMLStream(os) is not allowed once the first object is built).
 
 	// Parsing main loop.
 	for (pos_type i = initial; i < size(); ++i) {
@@ -3361,7 +3362,6 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
 		if (getInset(i) != nullptr && getInset(i)->lyxCode() == NEWLINE_CODE) {
 			generatedParagraphs.push_back(os.str());
 			os = odocstringstream();
-			// XMLStream has no copy constructor.
 			delete xs;
 			xs = new XMLStream(os);
 		}
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 800cbeb..5847121 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2420,10 +2420,16 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
 	docstring name;
 	if (getType() == hullSimple)
 		name = from_ascii("inlineequation");
-	else
+	else {
+		// This is a block equation, always have <informalequation> on its own line.
+		if (!xs.isLastTagCR())
+			xs << xml::CR();
+
 		name = from_ascii("informalequation");
+	}
 
 	// DocBook also has <equation>, but it comes with a title.
+	// TODO: recognise \tag from amsmath?
 
 	docstring attr;
 	for (row_type i = 0; i < nrows(); ++i) {
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 9d51853..e609f39 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -446,10 +446,16 @@ void makeParagraph(
 			special_case = true;
 	}
 
+	size_t nInsets = std::distance(par->insetList().begin(), par->insetList().end());
+
 	// Plain layouts must be ignored.
-	if (!special_case && buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars)
-		special_case = true;
-	// TODO: Could get rid of this with a DocBook equivalent to htmlisblock?
+	special_case |= buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars;
+	// Equations do not deserve their own paragraph (DocBook allows them outside paragraphs).
+	special_case |= nInsets == par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
+		return inset.inset && inset.inset->asInsetMath();
+	});
+
+	// TODO: Could get rid of this with a DocBook equivalent to htmlisblock? Not for all cases, unfortunately... See above for those that have been determined not to be allowable for this potential refactoring.
 	if (!special_case && par->size() == 1 && par->getInset(0)) {
 		Inset const * firstInset = par->getInset(0);
 
@@ -460,10 +466,6 @@ void makeParagraph(
 		if (!special_case && firstInset->asInsetCommand())
 			special_case = firstInset->asInsetCommand()->params().getCmdName() == "bibtex";
 
-		// Equations do not deserve their own paragraph (DocBook allows them outside paragraphs).
-		if (!special_case && firstInset->asInsetMath())
-			special_case = true;
-
 		// ERTs are in comments, not paragraphs.
 		if (!special_case && firstInset->lyxCode() == lyx::ERT_CODE)
 			special_case = true;

commit 0f2a1bd8230ebd751a3a921200928848d826c8f0
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Aug 29 18:40:31 2020 +0200

    DocBook: fix indentation for section titles (including stars).

diff --git a/autotests/export/docbook/basic.lyx b/autotests/export/docbook/basic.lyx
index 0bd87ce..1735dc4 100644
--- a/autotests/export/docbook/basic.lyx
+++ b/autotests/export/docbook/basic.lyx
@@ -1,5 +1,5 @@
-#LyX 2.4 created this file. For more info see http://www.lyx.org/
-\lyxformat 544
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 598
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -9,11 +9,11 @@
 \newcommand{\testmacro}{\ensuremath{\operatorname{testmacro}}}
 \end_preamble
 \use_default_options true
-\maintain_unincluded_children false
+\maintain_unincluded_children no
 \language english
 \language_package default
-\inputencoding auto
-\fontencoding global
+\inputencoding auto-legacy
+\fontencoding auto
 \font_roman "default" "default"
 \font_sans "default" "default"
 \font_typewriter "default" "default"
@@ -21,7 +21,9 @@
 \font_default_family default
 \use_non_tex_fonts false
 \font_sc false
-\font_osf 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
@@ -56,6 +58,7 @@
 \justification true
 \use_refstyle 1
 \use_minted 0
+\use_lineno 0
 \index Index
 \shortcut idx
 \color #008000
@@ -75,11 +78,15 @@
 \papercolumns 1
 \papersides 1
 \paperpagestyle default
+\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 false
+\docbook_table_output 0
 \end_header
 
 \begin_body
@@ -140,6 +147,10 @@ I am a quote
 \end_layout
 
 \begin_layout Standard
+Now, we're outside quotes.
+\end_layout
+
+\begin_layout Standard
 \begin_inset Formula 
 \[
 Formula!
@@ -386,6 +397,8 @@ Now, three tables:
 
 \begin_layout Standard
 \begin_inset Float table
+placement document
+alignment document
 wide false
 sideways false
 status open
@@ -511,6 +524,8 @@ I am a table caption below the table.
 
 \begin_layout Standard
 \begin_inset Float table
+placement document
+alignment document
 wide false
 sideways false
 status open
@@ -636,6 +651,8 @@ Col 3, row 2
 
 \begin_layout Standard
 \begin_inset Float table
+placement document
+alignment document
 wide false
 sideways false
 status open
@@ -753,6 +770,8 @@ Then, one figure:
 
 \begin_layout Standard
 \begin_inset Float figure
+placement document
+alignment document
 wide false
 sideways false
 status open
diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml
index 6f4a828..7980289 100644
--- a/autotests/export/docbook/basic.xml
+++ b/autotests/export/docbook/basic.xml
@@ -29,6 +29,7 @@
  </m:math>
 </inlineequation>. </para>
 </blockquote>
+<para>Now, we're outside quotes.</para>
 <para><informalequation>
 <alt role='tex'>Formula!</alt>
  <m:math>
@@ -72,22 +73,37 @@
 </section>
 <section>
 <title>I am the third section and I have fun with lists</title>
-<orderedlist><listitem>First item. 
-<br />
-Second line of the first item, after a line break. </listitem></orderedlist>
-<orderedlist><listitem>Second item. </listitem></orderedlist>
-<itemizedlist><listitem>Item has no order (1). </listitem></itemizedlist>
-<itemizedlist><listitem>Item has no order (2). </listitem></itemizedlist>
-<variablelist><listitem><varlistentry>
-
-Word description<!-- Output Error: Closing tag `listitem' when other tags are open, namely: -->
-<!-- Output Error: varlistentry -->
-</varlistentry></listitem></variablelist>
-<variablelist><listitem><varlistentry>
-
-Sentence meaning<!-- Output Error: Closing tag `listitem' when other tags are open, namely: -->
-<!-- Output Error: varlistentry -->
-</varlistentry></listitem></variablelist>
+<orderedlist>
+<listitem>
+<para>First item. </para>
+<para>Second line of the first item, after a line break. </para>
+</listitem>
+<listitem>
+<para>Second item. </para>
+</listitem>
+</orderedlist>
+<itemizedlist>
+<listitem>
+<para>Item has no order (1). </para>
+</listitem>
+<listitem>
+<para>Item has no order (2). </para>
+</listitem>
+</itemizedlist>
+<variablelist>
+<varlistentry>
+<term>Word</term>
+<listitem>
+<para>description</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>Sentence</term>
+<listitem>
+<para>meaning</para>
+</listitem>
+</varlistentry>
+</variablelist>
 </section>
 <section>
 <title>I am the fourth section and I deal with formatting. </title>
@@ -95,9 +111,11 @@ Sentence meaning<!-- Output Error: Closing tag `listitem' when other tags are op
 <para><programlisting>I am some code. 
 I am a second line of code. 
 </programlisting>I am no more code. </para>
-<para>This line has inline code. <code>This has typewriter font</code><footnote><para>I repeat that in a footnote.</para>
+<para>This line has inline code. <code>This has typewriter font</code><footnote>
+<para>I repeat that in a footnote.</para>
 </footnote>. </para>
-<para>On the other hand, <footnote><para>this footnote</para>
+<para>On the other hand, <footnote>
+<para>this footnote</para>
 <para>has multiple </para>
 <para>paragraphs.</para>
 </footnote>. </para>
@@ -145,7 +163,7 @@ I am a second line of code.
 </tr>
 </tbody>
 </table>
-<informaltable>
+<table>
 <tbody>
 <tr>
 <td align='center' valign='top'>Table that has no caption 1</td>
@@ -163,7 +181,8 @@ I am a second line of code.
 <td align='center' valign='top'>Col 3, row 2</td>
 </tr>
 </tbody>
-</informaltable>
+</table>
+
 <para>Then, one figure: </para>
 <figure>
 <title>Caption.</title>
@@ -334,5 +353,4 @@ I am a second line of code.
 </author>
 </authorgroup>
 </biblioentry>
-</bibliography>
-</article>
\ No newline at end of file
+</bibliography></article>
\ No newline at end of file
diff --git a/lib/layouts/stdsections.inc b/lib/layouts/stdsections.inc
index fa42eac..30b64ea 100644
--- a/lib/layouts/stdsections.inc
+++ b/lib/layouts/stdsections.inc
@@ -7,7 +7,7 @@
 # commands that are useful for article-like document classes, but not
 # for letters.
 
-Format 82
+Format 84
 
 Style Part
 	Category              Sectioning
@@ -40,6 +40,7 @@ Style Part
 	EndFont
 	HTMLTag               h1
 	DocBookTag            title
+	DocBookTagType        paragraph
 	DocBookSectionTag     part
 	DocBookForceAbstractTag	partintro
 End
@@ -75,6 +76,7 @@ Style Chapter
 	EndFont
 	HTMLTag               h1
 	DocBookTag            title
+	DocBookTagType        paragraph
 	DocBookSectionTag     chapter
 End
 
@@ -108,6 +110,7 @@ Style Section
 	EndFont
 	HTMLTag               h2
 	DocBookTag            title
+	DocBookTagType        paragraph
 	DocBookSectionTag     section
 End
 

commit f5502ff1a073818177e64bad4c9accd16294d861
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Thu Aug 27 00:52:06 2020 +0200

    DocBook: rewrite makeListEnvironment.

diff --git a/autotests/export/docbook/lists.lyx b/autotests/export/docbook/lists.lyx
index f4a58c2..1c1e88b 100644
--- a/autotests/export/docbook/lists.lyx
+++ b/autotests/export/docbook/lists.lyx
@@ -102,11 +102,71 @@ Second item on two lines
 I'm the second line
 \end_layout
 
+\begin_layout Itemize
+Third item
+\end_layout
+
 \begin_layout Standard
-\begin_inset Note Note
-status collapsed
+A simple enumerated list: 
+\end_layout
+
+\begin_layout Enumerate
+First item
+\end_layout
+
+\begin_layout Enumerate
+Second item on two lines
+\begin_inset Newline newline
+\end_inset
+
+I'm the second line
+\end_layout
+
+\begin_layout Standard
+A simple description list: 
+\end_layout
+
+\begin_layout Description
+Word description
+\end_layout
+
+\begin_layout Description
+Sentence meaning
+\end_layout
+
+\begin_layout Standard
+Nested lists:
+\end_layout
+
+\begin_layout Itemize
+First item
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+First first item
+\end_layout
+
+\begin_layout Itemize
+First second item
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+Second item
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Second first item
+\end_layout
+
+\begin_layout Itemize
+Second second item
+\end_layout
 
-\begin_layout Plain Layout
+\end_deeper
+\begin_layout Standard
 A complex list:
 \end_layout
 
@@ -123,7 +183,47 @@ First first item
 First second item
 \end_layout
 
-\begin_layout Plain Layout
+\begin_layout Standard
+Text after first item
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+Second item
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Second first item
+\end_layout
+
+\begin_layout Itemize
+Second second item
+\end_layout
+
+\begin_layout Standard
+Text after second item
+\end_layout
+
+\end_deeper
+\begin_layout Standard
+A very complex list:
+\end_layout
+
+\begin_layout Itemize
+First item
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+First first item
+\end_layout
+
+\begin_layout Itemize
+First second item
+\end_layout
+
+\begin_layout Standard
 Text after first item
 \end_layout
 
@@ -141,15 +241,32 @@ Second first item
 Second second item
 \end_layout
 
-\begin_layout Plain Layout
+\begin_layout Standard
 Text after second item
 \end_layout
 
 \end_deeper
-\end_inset
+\begin_layout Standard
+Nested description lists: 
+\end_layout
 
+\begin_layout Description
+LyX:
+\end_layout
 
+\begin_deeper
+\begin_layout Description
+lyx16 LyX 1.6 file format (lyx2lyx)
+\end_layout
+
+\begin_layout Description
+lyx21 LyX 2.1 file format (lyx2lyx)
 \end_layout
 
+\begin_layout Description
+xhtml LyXHTML (native LyX HTML export)
+\end_layout
+
+\end_deeper
 \end_body
 \end_document
diff --git a/autotests/export/docbook/lists.xml b/autotests/export/docbook/lists.xml
index d7b24f6..6812230 100644
--- a/autotests/export/docbook/lists.xml
+++ b/autotests/export/docbook/lists.xml
@@ -12,5 +12,141 @@
 <para>Second item on two lines</para>
 <para>I'm the second line</para>
 </listitem>
+<listitem>
+<para>Third item</para>
+</listitem>
+</itemizedlist>
+<para>A simple enumerated list: </para>
+<orderedlist>
+<listitem>
+<para>First item</para>
+</listitem>
+<listitem>
+<para>Second item on two lines</para>
+<para>I'm the second line</para>
+</listitem>
+</orderedlist>
+<para>A simple description list: </para>
+<variablelist>
+<varlistentry>
+<term>Word</term>
+<listitem>
+<para>description</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>Sentence</term>
+<listitem>
+<para>meaning</para>
+</listitem>
+</varlistentry>
+</variablelist>
+<para>Nested lists:</para>
+<itemizedlist>
+<listitem>
+<para>First item</para>
+<itemizedlist>
+<listitem>
+<para>First first item</para>
+</listitem>
+<listitem>
+<para>First second item</para>
+</listitem>
+</itemizedlist>
+</listitem>
+<listitem>
+<para>Second item</para>
+<itemizedlist>
+<listitem>
+<para>Second first item</para>
+</listitem>
+<listitem>
+<para>Second second item</para>
+</listitem>
+</itemizedlist>
+</listitem>
+</itemizedlist>
+<para>A complex list:</para>
+<itemizedlist>
+<listitem>
+<para>First item</para>
+<itemizedlist>
+<listitem>
+<para>First first item</para>
+</listitem>
+<listitem>
+<para>First second item</para>
+</listitem>
+</itemizedlist>
+<para>Text after first item</para>
+</listitem>
+<listitem>
+<para>Second item</para>
+<itemizedlist>
+<listitem>
+<para>Second first item</para>
+</listitem>
+<listitem>
+<para>Second second item</para>
+</listitem>
+</itemizedlist>
+<para>Text after second item</para>
+</listitem>
+</itemizedlist>
+<para>A very complex list:</para>
+<itemizedlist>
+<listitem>
+<para>First item</para>
+<itemizedlist>
+<listitem>
+<para>First first item</para>
+</listitem>
+<listitem>
+<para>First second item</para>
+</listitem>
 </itemizedlist>
+<para>Text after first item</para>
+</listitem>
+<listitem>
+<para>Second item</para>
+<orderedlist>
+<listitem>
+<para>Second first item</para>
+</listitem>
+<listitem>
+<para>Second second item</para>
+</listitem>
+</orderedlist>
+<para>Text after second item</para>
+</listitem>
+</itemizedlist>
+<para>Nested description lists: </para>
+<variablelist>
+<varlistentry>
+<term>LyX:</term>
+<listitem>
+
+<variablelist>
+<varlistentry>
+<term>lyx16</term>
+<listitem>
+<para>LyX 1.6 file format (lyx2lyx)</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>lyx21</term>
+<listitem>
+<para>LyX 2.1 file format (lyx2lyx)</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>xhtml</term>
+<listitem>
+<para>LyXHTML (native LyX HTML export)</para>
+</listitem>
+</varlistentry>
+</variablelist>
+</listitem>
+</varlistentry>
+</variablelist>
 </article>
\ No newline at end of file
diff --git a/lib/layouts/stdlists.inc b/lib/layouts/stdlists.inc
index c0b346d..d05e896 100644
--- a/lib/layouts/stdlists.inc
+++ b/lib/layouts/stdlists.inc
@@ -43,9 +43,7 @@ Style Itemize
 			Color latex
 		EndFont
 	EndArgument
-	DocBookWrapperTag     itemizedlist
-	DocBookWrapperMergeWithPrevious    true
-	DocBookTag            NONE
+	DocBookTag            itemizedlist
 	DocBookItemTag        listitem
 	DocBookItemInnerTag   para
 End
@@ -134,6 +132,7 @@ Style Description
 	DocBookItemTag        listitem
 	DocBookItemInnerTag   para
 	DocBookItemLabelTag   term
+	DocBookItemLabelTagType   paragraph
 End
 
 
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 356de07..9d51853 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -225,7 +225,7 @@ void closeBlockTag(XMLStream & xs, const std::string & tag)
 
 void openTag(XMLStream & xs, const std::string & tag, const std::string & attr, const std::string & tagtype)
 {
-	if (tag.empty() || tag == "NONE")
+	if (tag.empty() || tag == "NONE") // Common check to be performed elsewhere, if it was not here.
 		return;
 
 	if (tag == "para" || tagtype == "paragraph") // Special case for <para>: always considered as a paragraph.
@@ -275,7 +275,7 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar
 		Layout const & prevlay = prevpar->layout();
 		if (prevlay.docbookwrappertag() != "NONE") {
 			openWrapper = prevlay.docbookwrappertag() == lay.docbookwrappertag()
-					&& !lay.docbookwrappermergewithprevious();
+			              && !lay.docbookwrappermergewithprevious();
 		}
 	}
 
@@ -308,32 +308,8 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa
 	if (nextpar != nullptr) {
 		Layout const & nextlay = nextpar->layout();
 		if (nextlay.docbookwrappertag() != "NONE") {
-			if (nextpar->getDepth() == par->getDepth()) {
-				// Same depth: the basic condition applies.
-				closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag()
-				               && !nextlay.docbookwrappermergewithprevious();
-			} else if (nextpar->getDepth() > par->getDepth()) {
-				// The next paragraph is deeper: no need to close the wrapper, only to open it (cf. openParTag).
-				closeWrapper = 0;
-			} else {
-				// This paragraph is deeper than the next one: close the wrapper,
-				// disregarding docbookwrappermergewithprevious.
-				// Hypothesis: nextlay.docbookwrappertag() == lay.docbookwrappertag(). TODO: THIS IS WRONG! Loop back until a layout with the right depth is found?
-				closeWrapper = 1L + (long long) par->getDepth() - (long long) nextpar->getDepth(); // > 0, as nextpar->getDepth() < par->getDepth()
-			}
-		} else {
-			if (nextpar->getDepth() == par->getDepth()) {
-				// This is not wrapped: this must be the rest of the item, still within the wrapper.
-				closeWrapper = 1;
-			} else if (nextpar->getDepth() > par->getDepth()) {
-				// The next paragraph is deeper: no need to close the wrapper, only to open it (cf. openParTag).
-				closeWrapper = 0;
-			} else {
-				// This paragraph is deeper than the next one: close the wrapper,
-				// disregarding docbookwrappermergewithprevious.
-				// Hypothesis: nextlay.docbookwrappertag() == lay.docbookwrappertag(). TODO: THIS IS WRONG! Loop back until a layout with the right depth is found?
-				closeWrapper = 1L + (long long) par->getDepth() - (long long) nextpar->getDepth(); // > 0, as nextpar->getDepth() < par->getDepth()
-			}
+			closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag()
+			               && !nextlay.docbookwrappermergewithprevious();
 		}
 	}
 
@@ -564,9 +540,7 @@ void makeEnvironment(Text const &text,
 				// Usual cases: maybe there is something specified at the layout level. Highly unlikely, though.
 				docstring const lbl = par->params().labelString();
 
-				if (lbl.empty()) {
-					xs << xml::CR();
-				} else {
+				if (!lbl.empty()) {
 					openLabelTag(xs, style);
 					xs << lbl;
 					closeLabelTag(xs, style);
@@ -628,7 +602,6 @@ ParagraphList::const_iterator findEndOfEnvironment(
 		ParagraphList::const_iterator const & pend)
 {
 	// Copy-paste from XHTML. Should be factored out at some point...
-
 	ParagraphList::const_iterator p = pstart;
 	Layout const & bstyle = p->layout();
 	size_t const depth = p->params().depth();
@@ -662,95 +635,84 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text,
 												  Buffer const &buf,
 		                                          XMLStream &xs,
 		                                          OutputParams const &runparams,
-		                                          ParagraphList::const_iterator const & par)
+		                                          ParagraphList::const_iterator const & begin)
 {
+	auto par = begin;
 	auto const end = text.paragraphs().end();
+	auto const envend = findEndOfEnvironment(par, end);
 
-	// Output the opening tag for this environment, but only if it has not been previously opened (condition
-	// implemented in openParTag).
-	auto prevpar = text.paragraphs().getParagraphBefore(par);
-	openParTag(xs, &*par, prevpar); // TODO: switch in layout for par/block?
+	// Output the opening tag for this environment.
+	Layout const & envstyle = par->layout();
+	openTag(xs, envstyle.docbookwrappertag(), envstyle.docbookwrapperattr(), envstyle.docbookwrappertagtype());
+	openTag(xs, envstyle.docbooktag(), envstyle.docbookattr(), envstyle.docbooktagtype());
 
-	// Generate the contents of this environment. There is a special case if this is like some environment.
-	Layout const & style = par->layout();
-	if (style.latextype == LATEX_COMMAND) {
-		// Nothing to do (otherwise, infinite loops).
-	} else if (style.latextype == LATEX_ENVIRONMENT ||
-			style.latextype == LATEX_LIST_ENVIRONMENT ||
-			style.latextype == LATEX_ITEM_ENVIRONMENT) {
-		// Open a wrapper tag if needed.
-		if (style.docbookitemwrappertag() != "NONE")
-			openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype());
+	// Handle the content of the list environment, item by item.
+	while (par != envend) {
+		Layout const & style = par->layout();
+
+		// Open the item wrapper.
+		openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype());
 
 		// Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first
 		// character after the label.
 		pos_type sep = 0;
 		if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") {
-			// At least one condition must be met:
-			//  - this environment is not a list
-			//  - if this is a list, the label must not be manual (i.e. it must be taken from the layout)
-			if (style.latextype != LATEX_LIST_ENVIRONMENT || style.labeltype != LABEL_MANUAL) {
+			if (style.labeltype == LABEL_MANUAL) {
+				// Only variablelist gets here (or similar items defined as an extension in the layout).
+				openLabelTag(xs, style);
+				sep = 1 + par->firstWordDocBook(xs, runparams);
+				closeLabelTag(xs, style);
+			} else {
 				// Usual cases: maybe there is something specified at the layout level. Highly unlikely, though.
 				docstring const lbl = par->params().labelString();
 
-				if (lbl.empty()) {
-					xs << xml::CR();
-				} else {
+				if (!lbl.empty()) {
 					openLabelTag(xs, style);
 					xs << lbl;
 					closeLabelTag(xs, style);
 				}
-			} else {
-				// Only variablelist gets here (or similar items defined as an extension in the layout).
-				openLabelTag(xs, style);
-				sep = par->firstWordDocBook(xs, runparams);
-				closeLabelTag(xs, style);
 			}
 		}
 
-		// Maybe the item is completely empty, i.e. if the first word ends at the end of the current paragraph
-		// AND if the next paragraph doesn't have the same depth (if there is such a paragraph).
-		// Common case: there is only the first word on the line, but there is a nested list instead
-		// of more text.
-		bool emptyItem = false;
-		if (sep == par->size()) { // If the separator is already at the end of this paragraph...
-			auto next_par = par;
-			++next_par;
-			if (next_par == text.paragraphs().end()) // There is no next paragraph.
-				emptyItem = true;
-			else // There is a next paragraph: check depth.
-				emptyItem = par->params().depth() >= next_par->params().depth();
-		}
-
-		if (emptyItem) {
-			// Avoid having an empty item, this is not valid DocBook. A single character is enough to force
-			// generation of a full <para>.
-			// TODO: this always worked only by magic...
-			xs << ' ';
-		} else {
-			// Generate the rest of the paragraph, if need be. Open as many inner tags as necessary.
-			auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), sep);
-			auto p = pars.begin();
-			while (true) {
-				xs << XMLStream::ESCAPE_NONE << *p;
-				++p;
-				if (p != pars.end()) {
-					closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype());
-					openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype());
-				} else
-					break;
+		// Open the item (after the wrapper and the label).
+		openTag(xs, style.docbookitemtag(), style.docbookitemattr(), style.docbookitemtagtype());
+
+		// Generate the content of the item.
+		if (sep < par->size()) {
+			auto pars = par->simpleDocBookOnePar(buf, runparams,
+			                                     text.outerFont(std::distance(text.paragraphs().begin(), par)), sep);
+			for (auto &p : pars) {
+				openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(),
+				        par->layout().docbookiteminnertagtype());
+				xs << XMLStream::ESCAPE_NONE << p;
+				closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype());
 			}
+		} else {
+			// DocBook doesn't like emptiness.
+			openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(),
+			        par->layout().docbookiteminnertagtype());
+			closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype());
 		}
-	} else {
-		makeAny(text, buf, xs, runparams, par);
+
+		// If the next item is deeper, it must go entirely within this item (do it recursively).
+		// By construction, with findEndOfEnvironment, depth can only stay constant or increase, never decrease.
+		depth_type currentDepth = par->getDepth();
+		++par;
+		while (par != envend && par->getDepth() != currentDepth)
+			par = makeAny(text, buf, xs, runparams, par);
+		// Usually, this loop only makes one iteration, except in complex scenarios, like an item with a paragraph,
+		// a list, and another paragraph; or an item with two types of list (itemise then enumerate, for instance).
+
+		// Close the item.
+		closeTag(xs, style.docbookitemtag(), style.docbookitemtagtype());
+		closeTag(xs, style.docbookitemwrappertag(), style.docbookitemwrappertagtype());
 	}
 
-	// Close the environment.
-	auto nextpar = par;
-	++nextpar;
-	closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); // TODO: switch in layout for par/block?
+	// Close this environment in exactly the same way as it was opened.
+	closeTag(xs, envstyle.docbooktag(), envstyle.docbooktagtype());
+	closeTag(xs, envstyle.docbookwrappertag(), envstyle.docbookwrappertagtype());
 
-	return nextpar;
+	return envend;
 }
 
 
diff --git a/src/xml.cpp b/src/xml.cpp
index 2f49667..0daa9d8 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -185,6 +185,12 @@ void XMLStream::writeError(docstring const &s)
 }
 
 
+XMLStream::TagPtr XMLStream::getLastStackTag()
+{
+	return tag_stack_.back();
+}
+
+
 bool XMLStream::closeFontTags()
 {
 	if (isTagPending(xml::parsep_tag))
diff --git a/src/xml.h b/src/xml.h
index 45c62ab..56e5d81 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -125,7 +125,6 @@ private:
 	// own these pointers and how they will be deleted, so we use shared
 	// pointers.
 	///
-	typedef std::shared_ptr<xml::StartTag> TagPtr;
 	typedef std::deque<TagPtr> TagDeque;
 	///
 	template <typename T>

commit 06fe08dc294ec6a696f4c5bc7900ad01d6694ecd
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Aug 29 03:03:16 2020 +0200

    DocBook: start splitting environment handling in two, to have proper things for lists.

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 12c0089..356de07 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -370,12 +370,11 @@ void closeItemTag(XMLStream & xs, Layout const & lay)
 }
 
 
-void makeAny(
-		Text const &,
-		Buffer const &,
-		XMLStream &,
-		OutputParams const &,
-		ParagraphList::const_iterator);
+ParagraphList::const_iterator makeAny(Text const &,
+		                              Buffer const &,
+		                              XMLStream &,
+		                              OutputParams const &,
+		                              ParagraphList::const_iterator);
 
 
 void makeBibliography(
@@ -664,7 +663,6 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text,
 		                                          XMLStream &xs,
 		                                          OutputParams const &runparams,
 		                                          ParagraphList::const_iterator const & par)
->>>>>>> be6480e59c... DocBook: same refactoring for docbookSimpleAllParagraphs.
 {
 	auto const end = text.paragraphs().end();
 
@@ -751,6 +749,8 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text,
 	auto nextpar = par;
 	++nextpar;
 	closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); // TODO: switch in layout for par/block?
+
+	return nextpar;
 }
 
 
@@ -791,10 +791,12 @@ ParagraphList::const_iterator makeAny(Text const &text,
 		makeCommand(text, buf, xs, runparams, par);
 		break;
 	case LATEX_ENVIRONMENT:
+		makeEnvironment(text, buf, xs, runparams, par);
+		break;
 	case LATEX_LIST_ENVIRONMENT:
 	case LATEX_ITEM_ENVIRONMENT:
-		makeEnvironment(buf, xs, ourparams, text, par);
-		break;
+		// Only case when makeAny() might consume more than one paragraph.
+		return makeListEnvironment(text, buf, xs, runparams, par);
 	case LATEX_PARAGRAPH:
 		makeParagraph(text, buf, xs, runparams, par);
 		break;
@@ -802,6 +804,8 @@ ParagraphList::const_iterator makeAny(Text const &text,
 		makeBibliography(text, buf, xs, runparams, par);
 		break;
 	}
+	++par;
+	return par;
 }
 
 
@@ -1208,7 +1212,7 @@ void docbookParagraphs(Text const &text,
 		}
 
 		// Generate this paragraph.
-		makeAny(text, buf, xs, ourparams, par);
+		par = makeAny(text, buf, xs, ourparams, par);
 	}
 
 	// If need be, close <section>s, but only at the end of the document (otherwise, dealt with at the beginning

commit 70dd019e9ee64dc10aeba015cdc5ce8983fc8a52
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Aug 29 03:46:30 2020 +0200

    DocBook: make all make* functions have the same argument order.

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index ff47aa6..12c0089 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -378,11 +378,11 @@ void makeAny(
 		ParagraphList::const_iterator);
 
 
-void makeParagraphBibliography(
+void makeBibliography(
+		Text const & text,
 		Buffer const & buf,
 		XMLStream & xs,
 		OutputParams const & runparams,
-		Text const & text,
 		ParagraphList::const_iterator const & par)
 {
 	// If this is the first paragraph in a bibliography, open the bibliography tag.
@@ -433,10 +433,10 @@ void makeParagraphBibliography(
 
 
 void makeParagraph(
+		Text const & text,
 		Buffer const & buf,
 		XMLStream & xs,
 		OutputParams const & runparams,
-		Text const & text,
 		ParagraphList::const_iterator const & par)
 {
 	auto const begin = text.paragraphs().begin();
@@ -531,10 +531,10 @@ void makeParagraph(
 }
 
 
-void makeEnvironment(Buffer const &buf,
+void makeEnvironment(Text const &text,
+					 Buffer const &buf,
                      XMLStream &xs,
                      OutputParams const &runparams,
-                     Text const &text,
                      ParagraphList::const_iterator const & par)
 {
 	// TODO: simplify me!
@@ -659,10 +659,10 @@ ParagraphList::const_iterator findEndOfEnvironment(
 }
 
 
-ParagraphList::const_iterator makeListEnvironment(Buffer const &buf,
+ParagraphList::const_iterator makeListEnvironment(Text const &text,
+												  Buffer const &buf,
 		                                          XMLStream &xs,
 		                                          OutputParams const &runparams,
-		                                          Text const &text,
 		                                          ParagraphList::const_iterator const & par)
 >>>>>>> be6480e59c... DocBook: same refactoring for docbookSimpleAllParagraphs.
 {
@@ -755,10 +755,10 @@ ParagraphList::const_iterator makeListEnvironment(Buffer const &buf,
 
 
 void makeCommand(
+		Text const & text,
 		Buffer const & buf,
 		XMLStream & xs,
 		OutputParams const & runparams,
-		Text const & text,
 		ParagraphList::const_iterator const & par)
 {
 	// Unlike XHTML, no need for labels, as they are handled by DocBook tags.
@@ -780,16 +780,15 @@ void makeCommand(
 }
 
 
-void makeAny(
-		Text const &text,
-		Buffer const &buf,
-		XMLStream &xs,
-		OutputParams const &ourparams,
-		ParagraphList::const_iterator par)
+ParagraphList::const_iterator makeAny(Text const &text,
+		                              Buffer const &buf,
+		                              XMLStream &xs,
+		                              OutputParams const &runparams,
+		                              ParagraphList::const_iterator par)
 {
 	switch (par->layout().latextype) {
 	case LATEX_COMMAND:
-		makeCommand(buf, xs, ourparams, text, par);
+		makeCommand(text, buf, xs, runparams, par);
 		break;
 	case LATEX_ENVIRONMENT:
 	case LATEX_LIST_ENVIRONMENT:
@@ -797,10 +796,10 @@ void makeAny(
 		makeEnvironment(buf, xs, ourparams, text, par);
 		break;
 	case LATEX_PARAGRAPH:
-		makeParagraph(buf, xs, ourparams, text, par);
+		makeParagraph(text, buf, xs, runparams, par);
 		break;
 	case LATEX_BIB_ENVIRONMENT:
-		makeParagraphBibliography(buf, xs, ourparams, text, par);
+		makeBibliography(text, buf, xs, runparams, par);
 		break;
 	}
 }

commit 3c5326367ed6a3d5bfb702d00bdfeeb3378d9797
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Aug 29 02:55:47 2020 +0200

    DocBook: partially remove use of bpit/epit in docbookParagraphs and docbookSimpleAllParagraphs.
    
    This will help with the next refactoring to be much cleaner (only work with iterators, don't maintain twice the same information).

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 0dc5257..ff47aa6 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -308,8 +308,32 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa
 	if (nextpar != nullptr) {
 		Layout const & nextlay = nextpar->layout();
 		if (nextlay.docbookwrappertag() != "NONE") {
-			closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag()
-					&& !nextlay.docbookwrappermergewithprevious();
+			if (nextpar->getDepth() == par->getDepth()) {
+				// Same depth: the basic condition applies.
+				closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag()
+				               && !nextlay.docbookwrappermergewithprevious();
+			} else if (nextpar->getDepth() > par->getDepth()) {
+				// The next paragraph is deeper: no need to close the wrapper, only to open it (cf. openParTag).
+				closeWrapper = 0;
+			} else {
+				// This paragraph is deeper than the next one: close the wrapper,
+				// disregarding docbookwrappermergewithprevious.
+				// Hypothesis: nextlay.docbookwrappertag() == lay.docbookwrappertag(). TODO: THIS IS WRONG! Loop back until a layout with the right depth is found?
+				closeWrapper = 1L + (long long) par->getDepth() - (long long) nextpar->getDepth(); // > 0, as nextpar->getDepth() < par->getDepth()
+			}
+		} else {
+			if (nextpar->getDepth() == par->getDepth()) {
+				// This is not wrapped: this must be the rest of the item, still within the wrapper.
+				closeWrapper = 1;
+			} else if (nextpar->getDepth() > par->getDepth()) {
+				// The next paragraph is deeper: no need to close the wrapper, only to open it (cf. openParTag).
+				closeWrapper = 0;
+			} else {
+				// This paragraph is deeper than the next one: close the wrapper,
+				// disregarding docbookwrappermergewithprevious.
+				// Hypothesis: nextlay.docbookwrappertag() == lay.docbookwrappertag(). TODO: THIS IS WRONG! Loop back until a layout with the right depth is found?
+				closeWrapper = 1L + (long long) par->getDepth() - (long long) nextpar->getDepth(); // > 0, as nextpar->getDepth() < par->getDepth()
+			}
 		}
 	}
 
@@ -507,12 +531,140 @@ void makeParagraph(
 }
 
 
-void makeEnvironment(
-		Buffer const &buf,
-		XMLStream &xs,
-		OutputParams const &runparams,
-		Text const &text,
-		ParagraphList::const_iterator const & par)
+void makeEnvironment(Buffer const &buf,
+                     XMLStream &xs,
+                     OutputParams const &runparams,
+                     Text const &text,
+                     ParagraphList::const_iterator const & par)
+{
+	// TODO: simplify me!
+	auto const end = text.paragraphs().end();
+
+	// Output the opening tag for this environment, but only if it has not been previously opened (condition
+	// implemented in openParTag).
+	auto prevpar = text.paragraphs().getParagraphBefore(par);
+	openParTag(xs, &*par, prevpar); // TODO: switch in layout for par/block?
+
+	// Generate the contents of this environment. There is a special case if this is like some environment.
+	Layout const & style = par->layout();
+	if (style.latextype == LATEX_COMMAND) {
+		// Nothing to do (otherwise, infinite loops).
+	} else if (style.latextype == LATEX_ENVIRONMENT) {
+		// Open a wrapper tag if needed.
+		if (style.docbookitemwrappertag() != "NONE")
+			openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype());
+
+		// Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first
+		// character after the label.
+		pos_type sep = 0;
+		if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") {
+			// At least one condition must be met:
+			//  - this environment is not a list
+			//  - if this is a list, the label must not be manual (i.e. it must be taken from the layout)
+			if (style.latextype != LATEX_LIST_ENVIRONMENT || style.labeltype != LABEL_MANUAL) {
+				// Usual cases: maybe there is something specified at the layout level. Highly unlikely, though.
+				docstring const lbl = par->params().labelString();
+
+				if (lbl.empty()) {
+					xs << xml::CR();
+				} else {
+					openLabelTag(xs, style);
+					xs << lbl;
+					closeLabelTag(xs, style);
+				}
+			} else {
+				// Only variablelist gets here (or similar items defined as an extension in the layout).
+				openLabelTag(xs, style);
+				sep = par->firstWordDocBook(xs, runparams);
+				closeLabelTag(xs, style);
+			}
+		}
+
+		// Maybe the item is completely empty, i.e. if the first word ends at the end of the current paragraph
+		// AND if the next paragraph doesn't have the same depth (if there is such a paragraph).
+		// Common case: there is only the first word on the line, but there is a nested list instead
+		// of more text.
+		bool emptyItem = false;
+		if (sep == par->size()) { // If the separator is already at the end of this paragraph...
+			auto next_par = par;
+			++next_par;
+			if (next_par == text.paragraphs().end()) // There is no next paragraph.
+				emptyItem = true;
+			else // There is a next paragraph: check depth.
+				emptyItem = par->params().depth() >= next_par->params().depth();
+		}
+
+		if (emptyItem) {
+			// Avoid having an empty item, this is not valid DocBook. A single character is enough to force
+			// generation of a full <para>.
+			// TODO: this always worked only by magic...
+			xs << ' ';
+		} else {
+			// Generate the rest of the paragraph, if need be. Open as many inner tags as necessary.
+			auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), sep);
+			auto p = pars.begin();
+			while (true) {
+				xs << XMLStream::ESCAPE_NONE << *p;
+				++p;
+				if (p != pars.end()) {
+					closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype());
+					openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype());
+				} else
+					break;
+			}
+		}
+	} else {
+		makeAny(text, buf, xs, runparams, par);
+	}
+
+	// Close the environment.
+	auto nextpar = par;
+	++nextpar;
+	closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); // TODO: switch in layout for par/block?
+}
+
+
+ParagraphList::const_iterator findEndOfEnvironment(
+		ParagraphList::const_iterator const & pstart,
+		ParagraphList::const_iterator const & pend)
+{
+	// Copy-paste from XHTML. Should be factored out at some point...
+
+	ParagraphList::const_iterator p = pstart;
+	Layout const & bstyle = p->layout();
+	size_t const depth = p->params().depth();
+	for (++p; p != pend; ++p) {
+		Layout const & style = p->layout();
+		// It shouldn't happen that e.g. a section command occurs inside
+		// a quotation environment, at a higher depth, but as of 6/2009,
+		// it can happen. We pretend that it's just at lowest depth.
+		if (style.latextype == LATEX_COMMAND)
+			return p;
+
+		// If depth is down, we're done
+		if (p->params().depth() < depth)
+			return p;
+
+		// If depth is up, we're not done
+		if (p->params().depth() > depth)
+			continue;
+
+		// FIXME I am not sure about the first check.
+		// Surely we *could* have different layouts that count as
+		// LATEX_PARAGRAPH, right?
+		if (style.latextype == LATEX_PARAGRAPH || style != bstyle)
+			return p;
+	}
+	return pend;
+}
+
+
+ParagraphList::const_iterator makeListEnvironment(Buffer const &buf,
+		                                          XMLStream &xs,
+		                                          OutputParams const &runparams,
+		                                          Text const &text,
+		                                          ParagraphList::const_iterator const & par)
+>>>>>>> be6480e59c... DocBook: same refactoring for docbookSimpleAllParagraphs.
 {
 	auto const end = text.paragraphs().end();
 
@@ -921,12 +1073,13 @@ void docbookSimpleAllParagraphs(
 	outputDocBookInfo(text, buf, xs, runparams, paragraphs, info);
 
 	// Then, the content. It starts where the <info> ends.
-	bpit = info.epit;
-	while (bpit < epit) {
-		auto par = paragraphs.iterator_at(bpit);
+	auto par = text.paragraphs().iterator_at(info.epit);
+	auto end = text.paragraphs().iterator_at(epit);
+	while (par != end) {
 		if (!hasOnlyNotes(*par))
-			makeAny(text, buf, xs, runparams, par);
-		bpit += 1;
+			par = makeAny(text, buf, xs, runparams, par);
+		else
+			++par;
 	}
 }
 
@@ -967,21 +1120,20 @@ void docbookParagraphs(Text const &text,
 
 	bool currentlyInAppendix = false;
 
-	while (bpit < epit) {
+	auto par = text.paragraphs().iterator_at(bpit);
+	auto end = text.paragraphs().iterator_at(epit);
+	while (par != end) {
 		OutputParams ourparams = runparams;
 
-		auto par = paragraphs.iterator_at(bpit);
 		if (par->params().startOfAppendix())
 			currentlyInAppendix = true;
-		Layout const &style = par->layout();
-		ParagraphList::const_iterator const lastStartedPar = par;
-		ParagraphList::const_iterator send;
-
 		if (hasOnlyNotes(*par)) {
-			bpit += 1;
+			++par;
 			continue;
 		}
 
+		Layout const &style = par->layout();
+
 		// Think about adding <section> and/or </section>s.
 		const bool isLayoutSectioning = style.category() == from_utf8("Sectioning");
 		if (isLayoutSectioning) {
@@ -1058,7 +1210,6 @@ void docbookParagraphs(Text const &text,
 
 		// Generate this paragraph.
 		makeAny(text, buf, xs, ourparams, par);
-		bpit += 1;
 	}
 
 	// If need be, close <section>s, but only at the end of the document (otherwise, dealt with at the beginning

commit 87bb6000252fa99f426e8d405b61f970ad40f40c
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Aug 29 02:43:30 2020 +0200

    XML: use the new mechanisms for CR detection with errors.
    
    This helps tracking down line problems even in the presence of errors.

diff --git a/src/xml.cpp b/src/xml.cpp
index b4004af..2f49667 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -167,17 +167,21 @@ bool FontTag::operator==(StartTag const & tag) const
 } // namespace xml
 
 
-void XMLStream::writeError(std::string const &s) const
+void XMLStream::writeError(std::string const &s)
 {
 	LYXERR0(s);
-	os_ << from_utf8("<!-- Output Error: " + s + " -->\n");
+	*this << ESCAPE_NONE << from_utf8("<!-- Output Error: " + s + " -->");
+	*this << xml::CR();
 }
 
 
-void XMLStream::writeError(docstring const &s) const
+void XMLStream::writeError(docstring const &s)
 {
 	LYXERR0(s);
-	os_ << from_utf8("<!-- Output Error: ") << s << from_utf8(" -->\n");
+	*this << ESCAPE_NONE << from_utf8("<!-- Output Error: ");
+	*this << s;
+	*this << ESCAPE_NONE << from_utf8(" -->");
+	*this << xml::CR();
 }
 
 
diff --git a/src/xml.h b/src/xml.h
index 9a7cf17..45c62ab 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -103,9 +103,13 @@ public:
 	/// that simplifies the logic using this code.
 	bool isLastTagCR() const { return is_last_tag_cr_; };
 	///
-	void writeError(std::string const &) const;
+	void writeError(std::string const &);
 	///
-	void writeError(docstring const &) const;
+	void writeError(docstring const &);
+	///
+	typedef std::shared_ptr<xml::StartTag> TagPtr;
+	/// Returns the last element on the tag stack. XMLStream keeps ownership of the item.
+	TagPtr getLastStackTag();
 private:
 	///
 	void clearTagDeque();

commit 94f2e7c117db4720e0bf4e86a0dc8a85b1f96ea0
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Wed Aug 26 21:19:38 2020 +0200

    DocBook: make Paragraph::simpleDocBookOnePar return a list of paragraphs.
    
    Before, it directly wrote to the XMLStream, but it made implementation of new lines tricky. Now, it returns the XML for each sub-paragraph (delimited by new lines) as a string, so that the caller can adopt a more precise behaviour (such as in lists).

diff --git a/autotests/export/docbook/lists.lyx b/autotests/export/docbook/lists.lyx
index f903372..f4a58c2 100644
--- a/autotests/export/docbook/lists.lyx
+++ b/autotests/export/docbook/lists.lyx
@@ -103,6 +103,10 @@ I'm the second line
 \end_layout
 
 \begin_layout Standard
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Plain Layout
 A complex list:
 \end_layout
 
@@ -119,7 +123,7 @@ First first item
 First second item
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 Text after first item
 \end_layout
 
@@ -137,10 +141,15 @@ Second first item
 Second second item
 \end_layout
 
-\begin_layout Standard
+\begin_layout Plain Layout
 Text after second item
 \end_layout
 
 \end_deeper
+\end_inset
+
+
+\end_layout
+
 \end_body
 \end_document
diff --git a/autotests/export/docbook/lists.xml b/autotests/export/docbook/lists.xml
index 4621e30..d7b24f6 100644
--- a/autotests/export/docbook/lists.xml
+++ b/autotests/export/docbook/lists.xml
@@ -2,61 +2,15 @@
 <!-- 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>
-Test document
-</title>
-<para>
-A simple list: 
-</para>
+<title>Test document</title>
+<para>A simple list: </para>
 <itemizedlist>
 <listitem>
 <para>First item</para>
 </listitem>
 <listitem>
-<para>Second item on two lines<!-- Is para open? yes --><!-- Output Error: Closing tag `para' when other tags are open, namely: -->
-<!-- Output Error: &LyX_parsep_tag& -->
-</para>
-<para>I'm the second line<!-- Output Error: Tags still open in closeFontTags(). Probably not a problem,
-but you might want to check these tags: -->
-<!-- Output Error: para -->
-<!-- Output Error: listitem -->
-<!-- Output Error: itemizedlist -->
-<!-- Output Error: No division separation tag found in endDivision(). -->
-</para>
+<para>Second item on two lines</para>
+<para>I'm the second line</para>
 </listitem>
 </itemizedlist>
-<para>
-A complex list:
-</para>
-<itemizedlist>
-<listitem>
-<para>First item</para>
-</listitem>
-<listitem>
-<para>First first item</para>
-</listitem>
-<listitem>
-<para>First second item</para>
-</listitem>
-</itemizedlist>
-<para>
-Text after first item
-</para>
-<itemizedlist>
-<listitem>
-<para>Second item</para>
-</listitem>
-</itemizedlist>
-<orderedlist><listitem>
-<para>Second first item</para>
-</listitem>
-</orderedlist>
-<orderedlist><listitem>
-<para>Second second item</para>
-</listitem>
-</orderedlist>
-<para>
-Text after second item
-</para>
-
 </article>
\ No newline at end of file
diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index d6f5f17..357845a 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -27479,6 +27479,8 @@ status collapsed
 
 \change_inserted 1075283030 1597698872
 DocBookTagType
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -27542,6 +27544,8 @@ status collapsed
 
 \change_inserted 1075283030 1597698987
 DocBook*TagType
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -27563,6 +27567,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699012
 block
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -27621,6 +27627,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699113
 paragraph
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -27667,6 +27675,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699307
 inline
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -27702,6 +27712,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699585
 block
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -28415,8 +28427,34 @@ NONE
  This parameter only makes sense when itemising layouts are used, such as
  lists.
  
-\change_inserted 1075283030 1597699848
+\change_inserted 1075283030 1598469472
+The most likely value is 
+\begin_inset Quotes eld
+\end_inset
+
 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1598469476
+para
+\end_layout
+
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+.
+\begin_inset Newline newline
+\end_inset
+
+When a list item is split using a new line, the item inner tag will be repeated
+ for each part of the paragraph, parts being separated by new lines.
+ 
 \end_layout
 
 \begin_layout Description
@@ -28429,6 +28467,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699853
 DocBookItemInnerTagType
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -28441,6 +28481,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699866
 block, paragraph, inline
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -28594,6 +28636,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699880
 DocBookItemLabelTagType
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -28606,6 +28650,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699874
 block, paragraph, inline
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -28715,6 +28761,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699890
 DocBookItemTagType
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -28727,6 +28775,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699890
 block, paragraph, inline
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -28898,6 +28948,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699900
 DocBookItemWrapperTagType
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -28910,6 +28962,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699897
 block, paragraph, inline
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -29075,6 +29129,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699904
 DocBookInnerTagType
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -29087,6 +29143,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699904
 block, paragraph, inline
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -29238,6 +29296,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699924
 DocBookTagType
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -29250,6 +29310,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699924
 block, paragraph, inline
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -29415,6 +29477,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699932
 DocBookWrapperTagType
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -29427,6 +29491,8 @@ status collapsed
 
 \change_inserted 1075283030 1597699929
 block, paragraph, inline
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -29635,6 +29701,8 @@ status collapsed
 
 \change_inserted 1075283030 1597700120
 biblioentry
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -29660,6 +29728,8 @@ status collapsed
 
 \change_inserted 1075283030 1597700076
 bibliomixed
+\change_unchanged
+
 \end_layout
 
 \end_inset
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 24947f8..e87ef88 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -3329,19 +3329,14 @@ std::tuple<vector<xml::FontTag>, vector<xml::EndFontTag>> computeDocBookFontSwit
 } // anonymous namespace
 
 
-void Paragraph::simpleDocBookOnePar(Buffer const & buf,
-                                    XMLStream & xs,
-                                    OutputParams const & runparams,
-                                    Font const & outerfont,
-                                    bool start_paragraph, bool close_paragraph,
-                                    pos_type initial) const
+std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
+                                                      OutputParams const & runparams,
+                                                      Font const & outerfont,
+                                                      pos_type initial) const
 {
-	// track whether we have opened these tags
+	// Track whether we have opened these tags
 	DocBookFontState fs;
 
-	if (start_paragraph)
-		xs.startDivision(allowEmpty());
-
 	Layout const & style = *d->layout_;
 	FontInfo font_old =
 			style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
@@ -3352,15 +3347,27 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
 	vector<xml::FontTag> tagsToOpen;
 	vector<xml::EndFontTag> tagsToClose;
 
-	// parsing main loop
+	std::vector<docstring> generatedParagraphs;
+	odocstringstream os;
+	auto * xs = new XMLStream(os);
+
+	// Parsing main loop.
 	for (pos_type i = initial; i < size(); ++i) {
-		// let's not show deleted material in the output
+		// Don't show deleted material in the output.
 		if (isDeleted(i))
 			continue;
 
-		Font const font = getFont(buf.masterBuffer()->params(), i, outerfont);
+		// If this is an InsetNewline, generate a new paragraph.
+		if (getInset(i) != nullptr && getInset(i)->lyxCode() == NEWLINE_CODE) {
+			generatedParagraphs.push_back(os.str());
+			os = odocstringstream();
+			// XMLStream has no copy constructor.
+			delete xs;
+			xs = new XMLStream(os);
+		}
 
 		// Determine which tags should be opened or closed.
+		Font const font = getFont(buf.masterBuffer()->params(), i, outerfont);
 		tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(font_old, font, default_family, fs);
 
 		// FIXME XHTML
@@ -3369,12 +3376,12 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
 		vector<xml::EndFontTag>::const_iterator cit = tagsToClose.begin();
 		vector<xml::EndFontTag>::const_iterator cen = tagsToClose.end();
 		for (; cit != cen; ++cit)
-			xs << *cit;
+			*xs << *cit;
 
 		vector<xml::FontTag>::const_iterator sit = tagsToOpen.begin();
 		vector<xml::FontTag>::const_iterator sen = tagsToOpen.end();
 		for (; sit != sen; ++sit)
-			xs << *sit;
+			*xs << *sit;
 
 		tagsToClose.clear();
 		tagsToOpen.clear();
@@ -3386,11 +3393,11 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
 
 				// TODO: special case will bite here.
 				np.docbook_in_par = true;
-				inset->docbook(xs, np);
+				inset->docbook(*xs, np);
 			}
 		} else {
 			char_type c = getUChar(buf.masterBuffer()->params(), runparams, i);
-			xs << c;
+			*xs << c;
 		}
 		font_old = font.fontInfo();
 	}
@@ -3398,11 +3405,15 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
 	// FIXME, this code is just imported from XHTML
 	// I'm worried about what happens if a branch, say, is itself
 	// wrapped in some font stuff. I think that will not work.
-	xs.closeFontTags();
+	xs->closeFontTags();
 	if (runparams.docbook_in_listing)
-		xs << xml::CR();
-	if (close_paragraph)
-		xs.endDivision();
+		*xs << xml::CR();
+
+	// Finalise the last (and most likely only) paragraph.
+	generatedParagraphs.push_back(os.str());
+	delete xs;
+
+	return generatedParagraphs;
 }
 
 
diff --git a/src/Paragraph.h b/src/Paragraph.h
index 58b2762..ee31403 100644
--- a/src/Paragraph.h
+++ b/src/Paragraph.h
@@ -24,6 +24,7 @@
 #include "support/types.h"
 
 #include <set>
+#include <vector>
 
 namespace lyx {
 
@@ -208,14 +209,11 @@ public:
 	/// Output the first word of a paragraph, return the position where it left.
 	pos_type firstWordLyXHTML(XMLStream & xs, OutputParams const & runparams) const;
 
-	/// Writes to stream the DocBook representation
-	void simpleDocBookOnePar(Buffer const & buf,
-							 XMLStream &,
-							 OutputParams const & runparams,
-							 Font const & outerfont,
-							 bool start_paragraph = true,
-							 bool close_paragraph = true,
-							 pos_type initial = 0) const;
+	/// Outputs to stream the DocBook representation, one element per paragraph.
+	std::vector<docstring> simpleDocBookOnePar(Buffer const & buf,
+							                   OutputParams const & runparams,
+							                   Font const & outerfont,
+							                   pos_type initial = 0) const;
 
 	/// \return any material that has had to be deferred until after the
 	/// paragraph has closed.
diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp
index 8e69e88..1af67e1 100644
--- a/src/insets/InsetERT.cpp
+++ b/src/insets/InsetERT.cpp
@@ -98,23 +98,33 @@ void InsetERT::docbook(XMLStream & xs, OutputParams const & runparams) const
 	auto par = begin;
 	auto const end = paragraphs().end();
 
-	odocstringstream os2;
-	XMLStream xs2(os2);
+	odocstringstream os; // No need for XML handling here.
 
 	// Recreate the logic of makeParagraph in output_docbook.cpp, but much simplified: never open <para>
 	// in an ERT, use simple line breaks.
-	while (par != end) {
-		par->simpleDocBookOnePar(buffer(), xs2, runparams, text().outerFont(distance(begin, par)));
+	// New line after each paragraph of the ERT, save the last one.
+	while (true) { // For each paragraph in the ERT...
+		auto pars = par->simpleDocBookOnePar(buffer(), runparams, text().outerFont(distance(begin, par)));
+		auto p = pars.begin();
+		while (true) { // For each line of this ERT paragraph...
+			os << *p;
+			++p;
+			if (p != pars.end())
+				os << "\n";
+			else
+				break;
+		}
 
-		// New line after each paragraph of the ERT, save the last one.
 		++par;
 		if (par != end)
-			xs << "\n";
+			os << "\n";
+		else
+			break;
 	}
 
 	// Output the ERT as a comment with the appropriate escaping.
 	xs << XMLStream::ESCAPE_NONE << "<!-- ";
-	xs << XMLStream::ESCAPE_COMMENTS << os2.str();
+	xs << XMLStream::ESCAPE_COMMENTS << os.str();
 	xs << XMLStream::ESCAPE_NONE << " -->";
 	xs << xml::CR();
 }
diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp
index 7cba0f7..b33cf00 100644
--- a/src/insets/InsetNewline.cpp
+++ b/src/insets/InsetNewline.cpp
@@ -174,20 +174,7 @@ int InsetNewline::plaintext(odocstringstream & os,
 
 void InsetNewline::docbook(XMLStream & xs, OutputParams const & runparams) const
 {
-	if (runparams.docbook_in_par) {
-		xs.closeFontTags();
-
-		// TODO: what if within a list item, and docbookiteminnertag is not para? This would require information
-		// about the paragraph's layout... Good for now, though, this should not happen in DocBook, only maybe
-		// extensions.
-		xs << XMLStream::ESCAPE_NONE << from_utf8("<!-- Is para open? " + string((xs.isTagOpen(xml::StartTag("para"))) ? "yes" : "no") +" -->");
-		xs << XMLStream::ESCAPE_NONE << from_utf8("</para>\n<para>");
-		// TODO: that's a hack...
-//		xs << xml::EndTag("para");
-//		xs << xml::CR();
-//		xs << xml::StartTag("para");
-	}
-	// Outside a paragraph, no need to handle new lines.
+	// New lines are handled by Paragraph::simpleDocBookOnePar.
 }
 
 
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index ce3f699..0dc5257 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -382,9 +382,11 @@ void makeParagraphBibliography(
 	}
 	xs << xml::StartTag(from_utf8("bibliomixed"), attr);
 
-	// Generate the entry.
+	// Generate the entry. Concatenate the different parts of the paragraph if any.
 	auto const begin = text.paragraphs().begin();
-	par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(std::distance(begin, par)), true, true, 0);
+	auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(begin, par)), 0);
+	for (auto & parXML : pars)
+		xs << XMLStream::ESCAPE_NONE << parXML;
 
 	// End the precooked bibliography entry.
 	xs << xml::EndTag("bibliomixed");
@@ -488,21 +490,19 @@ void makeParagraph(
 	// Determine if this paragraph has some real content. Things like new pages are not caught
 	// by Paragraph::empty(), even though they do not generate anything useful in DocBook.
 	// Thus, remove all spaces (including new lines: \r, \n) before checking for emptiness.
-	odocstringstream os2;
-	XMLStream xs2(os2);
-	par->simpleDocBookOnePar(buf, xs2, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0);
-
-	docstring cleaned = os2.str();
-	cleaned.erase(std::remove_if(cleaned.begin(), cleaned.end(), ::isspace), cleaned.end());
-
-	if (!cleaned.empty()) {
-		if (open_par)
-			openParTag(xs, &*par, prevpar);
-
-		xs << XMLStream::ESCAPE_NONE << os2.str();
-
-		if (close_par)
-			closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr);
+	// std::all_of allows doing this check without having to copy the string.
+	// Open and close tags around each contained paragraph.
+	auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0);
+	for (auto & parXML : pars) {
+		if (!std::all_of(parXML.begin(), parXML.end(), ::isspace)) {
+			if (open_par)
+				openParTag(xs, &*par, prevpar);
+
+			xs << XMLStream::ESCAPE_NONE << parXML;
+
+			if (close_par)
+				closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr);
+		}
 	}
 }
 
@@ -529,10 +529,8 @@ void makeEnvironment(
 			style.latextype == LATEX_LIST_ENVIRONMENT ||
 			style.latextype == LATEX_ITEM_ENVIRONMENT) {
 		// Open a wrapper tag if needed.
-		if (style.docbookitemwrappertag() != "NONE") {
-			xs << xml::StartTag(style.docbookitemwrappertag(), style.docbookitemwrapperattr());
-			xs << xml::CR();
-		}
+		if (style.docbookitemwrappertag() != "NONE")
+			openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype());
 
 		// Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first
 		// character after the label.
@@ -580,9 +578,18 @@ void makeEnvironment(
 			// TODO: this always worked only by magic...
 			xs << ' ';
 		} else {
-			// Generate the rest of the paragraph, if need be.
-			par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)),
-							         true, true, sep);
+			// Generate the rest of the paragraph, if need be. Open as many inner tags as necessary.
+			auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), sep);
+			auto p = pars.begin();
+			while (true) {
+				xs << XMLStream::ESCAPE_NONE << *p;
+				++p;
+				if (p != pars.end()) {
+					closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype());
+					openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype());
+				} else
+					break;
+			}
 		}
 	} else {
 		makeAny(text, buf, xs, runparams, par);
@@ -612,8 +619,10 @@ void makeCommand(
 	auto prevpar = text.paragraphs().getParagraphBefore(par);
 	openParTag(xs, &*par, prevpar);
 
-	par->simpleDocBookOnePar(buf, xs, runparams,
-	                         text.outerFont(distance(begin, par)));
+	auto pars = par->simpleDocBookOnePar(buf, runparams,text.outerFont(distance(begin, par)));
+	for (auto & parXML : pars)
+		// TODO: decide what to do with openParTag/closeParTag in new lines.
+		xs << XMLStream::ESCAPE_NONE << parXML;
 
 	closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr);
 }
diff --git a/src/xml.h b/src/xml.h
index 69d582d..9a7cf17 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -132,8 +132,6 @@ private:
 	TagDeque tag_stack_;
 	///
 	bool is_last_tag_cr_;
-public:
-	bool pending_tags_empty() { return pending_tags_.empty();};
 };
 
 namespace xml {

commit e9f7b3ce79af5d058f304013904b91b8c25be303
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Aug 25 02:41:07 2020 +0200

    DocBook: fix compilation issues.

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 4e6c30e..ce3f699 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -30,8 +30,6 @@
 
 #include "support/lassert.h"
 
-#include "support/regex.h"
-
 #include <stack>
 #include <iostream>
 #include <algorithm>
@@ -166,18 +164,6 @@ string fontToAttribute(xml::FontTypes type) {
 }
 
 
-xml::FontTag docbookStartFontTag(xml::FontTypes type)
-{
-	return xml::FontTag(from_utf8(fontToDocBookTag(type)), from_utf8(fontToAttribute(type)), type);
-}
-
-
-xml::EndFontTag docbookEndFontTag(xml::FontTypes type)
-{
-	return xml::EndFontTag(from_utf8(fontToDocBookTag(type)), type);
-}
-
-
 // Convenience functions to open and close tags. First, very low-level ones to ensure a consistent new-line behaviour.
 // Block style:
 //	  Content before
@@ -501,13 +487,13 @@ void makeParagraph(
 
 	// Determine if this paragraph has some real content. Things like new pages are not caught
 	// by Paragraph::empty(), even though they do not generate anything useful in DocBook.
+	// Thus, remove all spaces (including new lines: \r, \n) before checking for emptiness.
 	odocstringstream os2;
 	XMLStream xs2(os2);
 	par->simpleDocBookOnePar(buf, xs2, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0);
 
 	docstring cleaned = os2.str();
-	static const lyx::regex reg("[ \\r\\n]*");
-	cleaned = from_utf8(lyx::regex_replace(to_utf8(cleaned), reg, string("")));
+	cleaned.erase(std::remove_if(cleaned.begin(), cleaned.end(), ::isspace), cleaned.end());
 
 	if (!cleaned.empty()) {
 		if (open_par)
@@ -658,8 +644,6 @@ void makeAny(
 	}
 }
 
-} // end anonymous namespace
-
 
 using DocBookDocumentSectioning = tuple<bool, pit_type>;
 
@@ -796,6 +780,20 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const &paragraphs, pit_type b
 	return DocBookInfoTag(shouldBeInInfo, mustBeInInfo, abstract, bpit, cpit);
 }
 
+} // end anonymous namespace
+
+
+xml::FontTag docbookStartFontTag(xml::FontTypes type)
+{
+	return xml::FontTag(from_utf8(fontToDocBookTag(type)), from_utf8(fontToAttribute(type)), type);
+}
+
+
+xml::EndFontTag docbookEndFontTag(xml::FontTypes type)
+{
+	return xml::EndFontTag(from_utf8(fontToDocBookTag(type)), type);
+}
+
 
 void outputDocBookInfo(
 		Text const & text,
@@ -829,11 +827,11 @@ void outputDocBookInfo(
 		// Actually output the abstract if there is something to do. Don't count line feeds or spaces in this,
 		// even though they must be properly output if there is some abstract.
 		abstract = os2.str();
-		static const lyx::regex reg("[ \\r\\n]*");
-		docstring abstractContent = from_utf8(lyx::regex_replace(to_utf8(abstract), reg, string("")));
+		docstring cleaned = abstract;
+		cleaned.erase(std::remove_if(cleaned.begin(), cleaned.end(), ::isspace), cleaned.end());
 
 		// Nothing? Then there is no abstract!
-		if (abstractContent.empty())
+		if (cleaned.empty())
 			hasAbstract = false;
 	}
 

commit 0681b0f16ec72e83350187d836cfbd1182bea260
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Aug 25 02:11:08 2020 +0200

    DocBook: Coverity potential problem for precooked bibliographies.

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 3f6a692..4e6c30e 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -386,9 +386,10 @@ void makeParagraphBibliography(
 	// Don't forget the citation ID!
 	docstring attr;
 	for (auto i = 0; i < par->size(); ++i) {
-		Inset const *ip = par->getInset(0);
-		if (ip != nullptr && ip->lyxCode() == BIBITEM_CODE) {
-			const auto * bibitem = dynamic_cast<const InsetBibitem*>(par->getInset(i));
+		Inset const *ip = par->getInset(i);
+		if (!ip)
+			continue;
+		if (const auto * bibitem = dynamic_cast<const InsetBibitem*>(ip)) {
 			attr = from_utf8("xml:id='") + bibitem->getParam("key") + from_utf8("'");
 			break;
 		}

commit 345a1fce9b768db6e5cfd520f98d2301ed69d035
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Aug 18 05:46:40 2020 +0200

    DocBook: simplify precooked bibliography code.

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 0481890..3f6a692 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -360,63 +360,59 @@ void closeItemTag(XMLStream & xs, Layout const & lay)
 }
 
 
+void makeAny(
+		Text const &,
+		Buffer const &,
+		XMLStream &,
+		OutputParams const &,
+		ParagraphList::const_iterator);
+
+
 void makeParagraphBibliography(
 		Buffer const & buf,
 		XMLStream & xs,
 		OutputParams const & runparams,
 		Text const & text,
-		ParagraphList::const_iterator const & pbegin)
+		ParagraphList::const_iterator const & par)
 {
-	auto const begin = text.paragraphs().begin();
-	auto const end = text.paragraphs().end();
-	auto pend = pbegin;
-	++pend;
-
-	// Find the paragraph *before* pbegin.
-	ParagraphList::const_iterator pbegin_before = begin;
-	if (pbegin != begin) {
-		ParagraphList::const_iterator pbegin_before_next = begin;
-		++pbegin_before_next;
-
-		while (pbegin_before_next != pbegin) {
-			++pbegin_before;
-			++pbegin_before_next;
-		}
-	}
-
-	ParagraphList::const_iterator par = pbegin;
-
 	// If this is the first paragraph in a bibliography, open the bibliography tag.
-	if (pbegin != begin && pbegin_before->layout().latextype != LATEX_BIB_ENVIRONMENT) {
+	auto pbegin_before = text.paragraphs().getParagraphBefore(par);
+	if (pbegin_before->layout().latextype != LATEX_BIB_ENVIRONMENT) {
 		xs << xml::StartTag("bibliography");
 		xs << xml::CR();
 	}
 
-	// Generate the required paragraphs, but only if they are .
-	for (; par != pend; ++par) {
-		// Start the precooked bibliography entry. This is very much like opening a paragraph tag.
-		// Don't forget the citation ID!
-		docstring attr;
-		for (auto i = 0; i < par->size(); ++i) {
-			Inset const *ip = par->getInset(0);
-			if (ip != nullptr && ip->lyxCode() == BIBITEM_CODE) {
-				const auto * bibitem = dynamic_cast<const InsetBibitem*>(par->getInset(i));
-				attr = from_utf8("xml:id='") + bibitem->getParam("key") + from_utf8("'");
-				break;
-			}
+	// Start the precooked bibliography entry. This is very much like opening a paragraph tag.
+	// Don't forget the citation ID!
+	docstring attr;
+	for (auto i = 0; i < par->size(); ++i) {
+		Inset const *ip = par->getInset(0);
+		if (ip != nullptr && ip->lyxCode() == BIBITEM_CODE) {
+			const auto * bibitem = dynamic_cast<const InsetBibitem*>(par->getInset(i));
+			attr = from_utf8("xml:id='") + bibitem->getParam("key") + from_utf8("'");
+			break;
 		}
-		xs << xml::StartTag(from_utf8("bibliomixed"), attr);
+	}
+	xs << xml::StartTag(from_utf8("bibliomixed"), attr);
 
-		// Generate the entry.
-		par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(distance(begin, par)), true, true, 0);
+	// Generate the entry.
+	auto const begin = text.paragraphs().begin();
+	par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(std::distance(begin, par)), true, true, 0);
 
-		// End the precooked bibliography entry.
-		xs << xml::EndTag("bibliomixed");
-		xs << xml::CR();
-	}
+	// End the precooked bibliography entry.
+	xs << xml::EndTag("bibliomixed");
+	xs << xml::CR();
 
 	// If this is the last paragraph in a bibliography, close the bibliography tag.
-	if (par == end || par->layout().latextype != LATEX_BIB_ENVIRONMENT) {
+	auto const end = text.paragraphs().end();
+	bool endBibliography = par == end;
+	if (!endBibliography) {
+		auto nextpar = par;
+		++nextpar;
+		endBibliography = par->layout().latextype != LATEX_BIB_ENVIRONMENT;
+	}
+
+	if (endBibliography) {
 		xs << xml::EndTag("bibliography");
 		xs << xml::CR();
 	}
@@ -524,14 +520,6 @@ void makeParagraph(
 }
 
 
-void makeAny(
-		Text const &text,
-		Buffer const &buf,
-		XMLStream &xs,
-		OutputParams const &ourparams,
-		ParagraphList::const_iterator par);
-
-
 void makeEnvironment(
 		Buffer const &buf,
 		XMLStream &xs,

commit a47e2c19314c68f7132d68ecb5a69050c857f7ba
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Aug 18 05:40:34 2020 +0200

    DocBook: remove useless includes.

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 12601c5..0481890 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -16,8 +16,6 @@
 #include "BufferParams.h"
 #include "Font.h"
 #include "InsetList.h"
-#include "Layout.h"
-#include "OutputParams.h"
 #include "Paragraph.h"
 #include "ParagraphList.h"
 #include "ParagraphParameters.h"
@@ -30,11 +28,7 @@
 #include "insets/InsetLabel.h"
 #include "insets/InsetNote.h"
 
-#include "support/convert.h"
-#include "support/debug.h"
 #include "support/lassert.h"
-#include "support/lstrings.h"
-#include "support/textutils.h"
 
 #include "support/regex.h"
 
@@ -159,6 +153,7 @@ string fontToRole(xml::FontTypes type)
 	}
 }
 
+
 string fontToAttribute(xml::FontTypes type) {
 	// If there is a role (i.e. nonstandard use of a tag), output the attribute. Otherwise, the sheer tag is sufficient
 	// for the font.

commit 18c313f10387660c64d8df10c9e7a45ca0336669
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Aug 18 05:39:46 2020 +0200

    More functions in anonymous namespace.

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index ad683c7..12601c5 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -170,8 +170,6 @@ string fontToAttribute(xml::FontTypes type) {
 	}
 }
 
-} // end anonymous namespace
-
 
 xml::FontTag docbookStartFontTag(xml::FontTypes type)
 {
@@ -185,8 +183,6 @@ xml::EndFontTag docbookEndFontTag(xml::FontTypes type)
 }
 
 
-namespace {
-
 // Convenience functions to open and close tags. First, very low-level ones to ensure a consistent new-line behaviour.
 // Block style:
 //	  Content before

commit afca5d0a88b7ef1f4f06d64e9a09469259ac709e
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Aug 18 05:37:46 2020 +0200

    DocBook: fine tuning of new lines.

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 9de281d..4477886 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2140,8 +2140,6 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os,
 	bool const output_body =
 	  output == FullSource || output == OnlyBody;
 
-	XMLStream xs(os);
-
 	if (output_preamble) {
 		// XML preamble, no doctype needed.
 		// Not using XMLStream for this, as the root tag would be in the tag stack and make troubles with the error
@@ -2164,16 +2162,17 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os,
 	}
 
 	if (output_body) {
-		params().documentClass().counters().reset();
-
 		// Start to output the document.
+		XMLStream xs(os);
 		docbookParagraphs(text(), *this, xs, runparams);
 	}
 
 	if (output_preamble) {
-		// Close the root element.
-		os << "\n</" << from_ascii(tclass.docbookroot()) << ">";
+		// Close the root element. No need for a line break, as free text is never allowed
+		// in a root element, it must always be wrapped in some container.
+		os << "</" << from_ascii(tclass.docbookroot()) << ">";
 	}
+
 	return ExportSuccess;
 }
 
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index b7b5941..ad683c7 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -239,7 +239,8 @@ void openBlockTag(XMLStream & xs, const std::string & tag, const std::string & a
 
 void closeBlockTag(XMLStream & xs, const std::string & tag)
 {
-	xs << xml::CR();
+	if (!xs.isLastTagCR())
+		xs << xml::CR();
 	xs << xml::EndTag(tag);
 	xs << xml::CR();
 }

commit 675e62706782cb0eb64b52dc53dd49532a47a958
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Aug 18 04:56:25 2020 +0200

    DocBook: improve comments.

diff --git a/src/xml.h b/src/xml.h
index 0948143..69d582d 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -39,7 +39,7 @@ struct CR;
 class XMLStream {
 public:
 	///
-	explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL), is_last_tag_cr_(false) {}
+	explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL), is_last_tag_cr_(true) {}
 	///
 	odocstream & os() { return os_; }
 	///
@@ -82,7 +82,7 @@ public:
 	enum EscapeSettings {
 		ESCAPE_NONE,
 		ESCAPE_AND, // meaning &
-		ESCAPE_ALL, // meaning <, >, &, at present
+		ESCAPE_ALL, // meaning <, >, &, at present, except things that are forbidden in comments
 		ESCAPE_COMMENTS // Anything that is forbidden within comments
 	};
 	/// Sets what we are going to escape on the NEXT write.
@@ -98,7 +98,9 @@ public:
 	bool isTagOpen(xml::EndTag const &, int maxdepth = -1) const;
 	///
 	bool isTagPending(xml::StartTag const &, int maxdepth = -1) const;
-	///
+	/// Is the last tag that was added to the stream a new line (CR)? This is mostly to known
+	/// whether a new line must be added. Therefore, consider that an empty stream just had a CR,
+	/// that simplifies the logic using this code.
 	bool isLastTagCR() const { return is_last_tag_cr_; };
 	///
 	void writeError(std::string const &) const;

commit dba20c7b5409660faa0232b09b475c43bc6b0e81
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Aug 18 00:37:34 2020 +0200

    DocBook: new logic to handle the new lines, only used in output_docbook for now.

diff --git a/lib/layouts/stdlayouts.inc b/lib/layouts/stdlayouts.inc
index 1670695..e550518 100644
--- a/lib/layouts/stdlayouts.inc
+++ b/lib/layouts/stdlayouts.inc
@@ -7,7 +7,7 @@
 # quotations and such.
 
 
-Format 82
+Format 84
 
 Style Quotation
 	Category              MainText
diff --git a/lib/layouts/stdlists.inc b/lib/layouts/stdlists.inc
index 16a9e81..c0b346d 100644
--- a/lib/layouts/stdlists.inc
+++ b/lib/layouts/stdlists.inc
@@ -6,7 +6,7 @@
 # This include files contains various standard environments for lists.
 
 
-Format 82
+Format 84
 
 Input stdlyxlist.inc
 
diff --git a/lib/layouts/stdstruct.inc b/lib/layouts/stdstruct.inc
index c8b7eb4..2a81117 100644
--- a/lib/layouts/stdstruct.inc
+++ b/lib/layouts/stdstruct.inc
@@ -8,7 +8,7 @@
 # a document, like abstract, bibliography and such.
 
 
-Format 82
+Format 84
 
 Style Abstract
 	Margin                Static
diff --git a/lib/layouts/stdtitle.inc b/lib/layouts/stdtitle.inc
index ad989a6..44b1b8e 100644
--- a/lib/layouts/stdtitle.inc
+++ b/lib/layouts/stdtitle.inc
@@ -8,7 +8,7 @@
 # a document, like title, author and such.
 
 
-Format 82
+Format 84
 
 Style Title
 	Margin                Static
@@ -29,6 +29,7 @@ Style Title
 	HTMLTag               h1
 	HTMLTitle             true
 	DocBookTag            title
+	DocBookTagType        paragraph
 	DocBookInInfo         maybe
 End
 
@@ -50,7 +51,9 @@ Style Author
 	  Size                Large
 	EndFont
 	DocBookTag            personname
+	DocBookTagType        paragraph
 	DocBookWrapperTag     author
+	DocBookWrapperTagType inline
 	DocBookInInfo         always
 End
 
@@ -72,5 +75,6 @@ Style Date
 	  Size                Large
 	EndFont
 	DocBookTag            date
+	DocBookTagType        paragraph
 	DocBookInInfo         always
 End
diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp
index 00b276e..7cba0f7 100644
--- a/src/insets/InsetNewline.cpp
+++ b/src/insets/InsetNewline.cpp
@@ -181,7 +181,7 @@ void InsetNewline::docbook(XMLStream & xs, OutputParams const & runparams) const
 		// about the paragraph's layout... Good for now, though, this should not happen in DocBook, only maybe
 		// extensions.
 		xs << XMLStream::ESCAPE_NONE << from_utf8("<!-- Is para open? " + string((xs.isTagOpen(xml::StartTag("para"))) ? "yes" : "no") +" -->");
-		xs << XMLStream::ESCAPE_NONE << from_utf8("</para>\n<para");
+		xs << XMLStream::ESCAPE_NONE << from_utf8("</para>\n<para>");
 		// TODO: that's a hack...
 //		xs << xml::EndTag("para");
 //		xs << xml::CR();
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index b29da56..b7b5941 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -43,8 +43,6 @@
 #include <algorithm>
 #include <sstream>
 
-// #define DOCBOOK_DEBUG_NEWLINES
-
 using namespace std;
 using namespace lyx::support;
 
@@ -189,14 +187,100 @@ xml::EndFontTag docbookEndFontTag(xml::FontTypes type)
 
 namespace {
 
-// convenience functions
+// Convenience functions to open and close tags. First, very low-level ones to ensure a consistent new-line behaviour.
+// Block style:
+//	  Content before
+//	  <blocktag>
+//	    Contents of the block.
+//	  </blocktag>
+//	  Content after
+// Paragraph style:
+//	  Content before
+//	    <paratag>Contents of the paragraph.</paratag>
+//	  Content after
+// Inline style:
+//    Content before<inlinetag>Contents of the paragraph.</inlinetag>Content after
+
+void openInlineTag(XMLStream & xs, const std::string & tag, const std::string & attr)
+{
+	xs << xml::StartTag(tag, attr);
+}
+
 
-void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar)
+void closeInlineTag(XMLStream & xs, const std::string & tag)
+{
+	xs << xml::EndTag(tag);
+}
+
+
+void openParTag(XMLStream & xs, const std::string & tag, const std::string & attr)
+{
+	if (!xs.isLastTagCR())
+		xs << xml::CR();
+	xs << xml::StartTag(tag, attr);
+}
+
+
+void closeParTag(XMLStream & xs, const std::string & tag)
+{
+	xs << xml::EndTag(tag);
+	xs << xml::CR();
+}
+
+
+void openBlockTag(XMLStream & xs, const std::string & tag, const std::string & attr)
+{
+	if (!xs.isLastTagCR())
+		xs << xml::CR();
+	xs << xml::StartTag(tag, attr);
+	xs << xml::CR();
+}
+
+
+void closeBlockTag(XMLStream & xs, const std::string & tag)
+{
+	xs << xml::CR();
+	xs << xml::EndTag(tag);
+	xs << xml::CR();
+}
+
+
+void openTag(XMLStream & xs, const std::string & tag, const std::string & attr, const std::string & tagtype)
+{
+	if (tag.empty() || tag == "NONE")
+		return;
+
+	if (tag == "para" || tagtype == "paragraph") // Special case for <para>: always considered as a paragraph.
+		openParTag(xs, tag, attr);
+	else if (tagtype == "block")
+		openBlockTag(xs, tag, attr);
+	else if (tagtype == "inline")
+		openInlineTag(xs, tag, attr);
+	else
+		xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + tag + " " + attr + "'");
+}
+
+
+void closeTag(XMLStream & xs, const std::string & tag, const std::string & tagtype)
 {
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- openParTag -->";
-#endif
+	if (tag.empty() || tag == "NONE")
+		return;
 
+	if (tag == "para" || tagtype == "paragraph") // Special case for <para>: always considered as a paragraph.
+		closeParTag(xs, tag);
+	else if (tagtype == "block")
+		closeBlockTag(xs, tag);
+	else if (tagtype == "inline")
+		closeInlineTag(xs, tag);
+	else
+		xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + tag + "'");
+}
+
+
+// Higher-level convenience functions.
+
+void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar)
+{
 	Layout const & lay = par->layout();
 
 	if (par == prevpar)
@@ -218,38 +302,25 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar
 	}
 
 	// Main logic.
-	if (openWrapper) {
-		xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr());
-		xs << xml::CR();
-	}
+	if (openWrapper)
+		openTag(xs, lay.docbookwrappertag(), lay.docbookwrapperattr(), lay.docbookwrappertagtype());
 
-	string tag = lay.docbooktag();
+	const string & tag = lay.docbooktag();
 	if (tag != "NONE") {
 		auto xmltag = xml::ParTag(tag, lay.docbookattr());
-		if (!xs.isTagOpen(xmltag, 1)) // Don't nest a paragraph directly in a paragraph. TODO: required or not?
-			xs << xmltag;
-	}
-
-	if (lay.docbookitemtag() != "NONE") {
-		xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr());
-		xs << xml::CR();
+		if (!xs.isTagOpen(xmltag, 1)) // Don't nest a paragraph directly in a paragraph.
+			// TODO: required or not?
+			// TODO: avoid creating a ParTag object just for this query...
+			openTag(xs, lay.docbooktag(), lay.docbookattr(), lay.docbooktagtype());
 	}
 
-	if (lay.docbookiteminnertag() != "NONE")
-		xs << xml::StartTag(lay.docbookiteminnertag(), lay.docbookiteminnerattr());
-
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- /openParTag -->";
-#endif
+	openTag(xs, lay.docbookitemtag(), lay.docbookitemattr(), lay.docbookitemtagtype());
+	openTag(xs, lay.docbookiteminnertag(), lay.docbookiteminnerattr(), lay.docbookiteminnertagtype());
 }
 
 
 void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpar)
 {
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- closeParTag -->";
-#endif
-
 	if (par == nextpar)
 		nextpar = nullptr;
 
@@ -265,119 +336,35 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa
 	}
 
 	// Main logic.
-	if (lay.docbookiteminnertag() != "NONE") {
-		xs << xml::EndTag(lay.docbookiteminnertag());
-		xs << xml::CR();
-	}
-
-	if (lay.docbookitemtag() != "NONE") {
-		xs << xml::EndTag(lay.docbookitemtag());
-		xs << xml::CR();
-	}
-
-	if (lay.docbooktag() != "NONE") {
-		xs << xml::EndTag(lay.docbooktag());
-		xs << xml::CR();
-	}
-
-	if (closeWrapper) {
-		xs << xml::EndTag(lay.docbookwrappertag());
-		xs << xml::CR();
-	}
-
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- /closeParTag -->";
-#endif
-}
-
-
-void openBlockTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar)
-{
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- openBlockTag -->";
-#endif
-
-	// Similar as openParTag, but with a line feed after.
-	openParTag(xs, par, prevpar);
-	xs << xml::CR();
-
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- /openBlockTag -->";
-#endif
-}
-
-
-void closeBlockTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar)
-{
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- closeBlockTag -->";
-#endif
-
-	// Similar as closeParTag, but with a line feed before.
-	xs << xml::CR();
-	closeParTag(xs, par, prevpar);
-
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- /closeBlockTag -->";
-#endif
+	closeTag(xs, lay.docbookiteminnertag(), lay.docbookiteminnertagtype());
+	closeTag(xs, lay.docbookitemtag(), lay.docbookitemtagtype());
+	closeTag(xs, lay.docbooktag(), lay.docbooktagtype());
+	if (closeWrapper)
+		closeTag(xs, lay.docbookwrappertag(), lay.docbookwrappertagtype());
 }
 
 
 void openLabelTag(XMLStream & xs, Layout const & lay) // Mostly for definition lists.
 {
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- openLabelTag -->";
-#endif
-
-	xs << xml::StartTag(lay.docbookitemlabeltag(), lay.docbookitemlabelattr());
-
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- /openLabelTag -->";
-#endif
+	openTag(xs, lay.docbookitemlabeltag(), lay.docbookitemlabelattr(), lay.docbookitemlabeltagtype());
 }
 
 
 void closeLabelTag(XMLStream & xs, Layout const & lay)
 {
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- closeLabelTag -->";
-#endif
-
-	xs << xml::EndTag(lay.docbookitemlabeltag());
-	xs << xml::CR();
-
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- closeLabelTag -->";
-#endif
+	closeTag(xs, lay.docbookitemlabeltag(), lay.docbookitemlabeltagtype());
 }
 
 
 void openItemTag(XMLStream & xs, Layout const & lay)
 {
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- openItemTag -->";
-#endif
-
-	xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr());
-
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- /openItemTag -->";
-#endif
+	openTag(xs, lay.docbookitemtag(), lay.docbookitemattr(), lay.docbookitemtagtype());
 }
 
 
 void closeItemTag(XMLStream & xs, Layout const & lay)
 {
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- closeItemTag -->";
-#endif
-
-	xs << xml::EndTag(lay.docbookitemtag());
-	xs << xml::CR();
-
-#ifdef DOCBOOK_DEBUG_NEWLINES
-	xs << XMLStream::ESCAPE_NONE << "<!-- /closeItemTag -->";
-#endif
+	closeTag(xs, lay.docbookitemtag(), lay.docbookitemtagtype());
 }
 
 
diff --git a/src/xml.h b/src/xml.h
index 581cca5..0948143 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -100,13 +100,13 @@ public:
 	bool isTagPending(xml::StartTag const &, int maxdepth = -1) const;
 	///
 	bool isLastTagCR() const { return is_last_tag_cr_; };
-private:
-	///
-	void clearTagDeque();
 	///
 	void writeError(std::string const &) const;
 	///
 	void writeError(docstring const &) const;
+private:
+	///
+	void clearTagDeque();
 	///
 	odocstream & os_;
 	///

commit b68620ce3d487034a2e81a4db7930a6a67f29268
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 17 23:44:02 2020 +0200

    XML: memorise if the last thing that is getting output is a line feed.

diff --git a/src/xml.cpp b/src/xml.cpp
index 147eadd..b4004af 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -290,6 +290,7 @@ void XMLStream::clearTagDeque()
 
 XMLStream &XMLStream::operator<<(docstring const &d)
 {
+	is_last_tag_cr_ = false;
 	clearTagDeque();
 	os_ << xml::escapeString(d, escape_);
 	escape_ = ESCAPE_ALL;
@@ -299,6 +300,7 @@ XMLStream &XMLStream::operator<<(docstring const &d)
 
 XMLStream &XMLStream::operator<<(const char *s)
 {
+	is_last_tag_cr_ = false;
 	clearTagDeque();
 	docstring const d = from_ascii(s);
 	os_ << xml::escapeString(d, escape_);
@@ -309,6 +311,7 @@ XMLStream &XMLStream::operator<<(const char *s)
 
 XMLStream &XMLStream::operator<<(char_type c)
 {
+	is_last_tag_cr_ = false;
 	clearTagDeque();
 	os_ << xml::escapeChar(c, escape_);
 	escape_ = ESCAPE_ALL;
@@ -318,6 +321,7 @@ XMLStream &XMLStream::operator<<(char_type c)
 
 XMLStream &XMLStream::operator<<(char c)
 {
+	is_last_tag_cr_ = false;
 	clearTagDeque();
 	os_ << xml::escapeChar(c, escape_);
 	escape_ = ESCAPE_ALL;
@@ -327,6 +331,7 @@ XMLStream &XMLStream::operator<<(char c)
 
 XMLStream &XMLStream::operator<<(int i)
 {
+	is_last_tag_cr_ = false;
 	clearTagDeque();
 	os_ << i;
 	escape_ = ESCAPE_ALL;
@@ -336,6 +341,7 @@ XMLStream &XMLStream::operator<<(int i)
 
 XMLStream &XMLStream::operator<<(EscapeSettings e)
 {
+	// Don't update is_last_tag_cr_ here, as this does not output anything.
 	escape_ = e;
 	return *this;
 }
@@ -343,6 +349,7 @@ XMLStream &XMLStream::operator<<(EscapeSettings e)
 
 XMLStream &XMLStream::operator<<(xml::StartTag const &tag)
 {
+	is_last_tag_cr_ = false;
 	if (tag.tag_.empty())
 		return *this;
 	pending_tags_.push_back(makeTagPtr(tag));
@@ -354,6 +361,7 @@ XMLStream &XMLStream::operator<<(xml::StartTag const &tag)
 
 XMLStream &XMLStream::operator<<(xml::ParTag const &tag)
 {
+	is_last_tag_cr_ = false;
 	if (tag.tag_.empty())
 		return *this;
 	pending_tags_.push_back(makeTagPtr(tag));
@@ -363,6 +371,7 @@ XMLStream &XMLStream::operator<<(xml::ParTag const &tag)
 
 XMLStream &XMLStream::operator<<(xml::CompTag const &tag)
 {
+	is_last_tag_cr_ = false;
 	if (tag.tag_.empty())
 		return *this;
 	clearTagDeque();
@@ -373,6 +382,7 @@ XMLStream &XMLStream::operator<<(xml::CompTag const &tag)
 
 XMLStream &XMLStream::operator<<(xml::FontTag const &tag)
 {
+	is_last_tag_cr_ = false;
 	if (tag.tag_.empty())
 		return *this;
 	pending_tags_.push_back(makeTagPtr(tag));
@@ -382,6 +392,7 @@ XMLStream &XMLStream::operator<<(xml::FontTag const &tag)
 
 XMLStream &XMLStream::operator<<(xml::CR const &)
 {
+	is_last_tag_cr_ = true;
 	clearTagDeque();
 	os_ << from_ascii("\n");
 	return *this;
@@ -434,6 +445,8 @@ bool XMLStream::isTagPending(xml::StartTag const &stag, int maxdepth) const
 // best to make things work.
 XMLStream &XMLStream::operator<<(xml::EndTag const &etag)
 {
+	is_last_tag_cr_ = false;
+
 	if (etag.tag_.empty())
 		return *this;
 
diff --git a/src/xml.h b/src/xml.h
index b585a48..581cca5 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -39,7 +39,7 @@ struct CR;
 class XMLStream {
 public:
 	///
-	explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL) {}
+	explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL), is_last_tag_cr_(false) {}
 	///
 	odocstream & os() { return os_; }
 	///
@@ -98,6 +98,8 @@ public:
 	bool isTagOpen(xml::EndTag const &, int maxdepth = -1) const;
 	///
 	bool isTagPending(xml::StartTag const &, int maxdepth = -1) const;
+	///
+	bool isLastTagCR() const { return is_last_tag_cr_; };
 private:
 	///
 	void clearTagDeque();
@@ -126,6 +128,8 @@ private:
 	TagDeque pending_tags_;
 	///
 	TagDeque tag_stack_;
+	///
+	bool is_last_tag_cr_;
 public:
 	bool pending_tags_empty() { return pending_tags_.empty();};
 };

commit 862daa5dedb0ca009ee74f9ee591a11823116255
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 17 23:35:40 2020 +0200

    DocBook: documentation for the new tags.

diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index 541e562..d6f5f17 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -27208,13 +27208,24 @@ Labels are rarely output, as they are redundant in DocBook: this information
 
 \begin_layout Subsection
 
-\change_inserted -970929547 1496610966
+\change_inserted 1075283030 1597699417
+\begin_inset CommandInset label
+LatexCommand label
+name "subsec:Paragraph-Style-DocBook"
+
+\end_inset
+
+
+\change_deleted 1075283030 1597699417
+
 \begin_inset CommandInset label
 LatexCommand label
 name "subsec:Paragraph-Style-XHTML-1"
 
 \end_inset
 
+
+\change_inserted -970929547 1496610966
 Paragraph styles
 \end_layout
 
@@ -27454,6 +27465,252 @@ tag
  in the example above.
  The default is the name of the float and always needs to be changed, as
  DocBook provides no generic tag.
+\change_inserted 1075283030 1597698868
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 1075283030 1597699399
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597698872
+DocBookTagType
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597700585
+block, paragraph, inline
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+] The new-line policy for this tag, see Section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:DocBook-New-line-policy"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+ for the details.
+ 
+\change_unchanged
+
+\end_layout
+
+\begin_layout Subsection
+
+\change_inserted 1075283030 1597699385
+New-line policy
+\begin_inset CommandInset label
+LatexCommand label
+name "subsec:DocBook-New-line-policy"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted 1075283030 1597698993
+For all tags, there are three possible policies for outputting new lines
+ (given in the 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597698987
+DocBook*TagType
+\end_layout
+
+\end_inset
+
+ attribute): 
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted 1075283030 1597699279
+\begin_inset Quotes eld
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699012
+block
+\end_layout
+
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+: the opening and closing tags are on their own lines (i.e.
+ a line feed after and before the opening and the closing tags).
+ Typical elements are floats.
+ For instance: 
+\end_layout
+
+\begin_layout LyX-Code
+
+\change_inserted 1075283030 1597699194
+Content before
+\end_layout
+
+\begin_layout LyX-Code
+
+\change_inserted 1075283030 1597699194
+<blocktag>
+\end_layout
+
+\begin_layout LyX-Code
+
+\change_inserted 1075283030 1597699098
+  Contents of the block.
+\end_layout
+
+\begin_layout LyX-Code
+
+\change_inserted 1075283030 1597699196
+</blocktag>
+\end_layout
+
+\begin_layout LyX-Code
+
+\change_inserted 1075283030 1597699198
+Content after
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted 1075283030 1597699289
+\begin_inset Quotes eld
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699113
+paragraph
+\end_layout
+
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+: the opening and closing tags are on the same, new line; a line feed is
+ output before the opening tag and after the closing tag.
+ Typical elements are paragraphs and list items.
+ For instance: 
+\end_layout
+
+\begin_layout LyX-Code
+
+\change_inserted 1075283030 1597699186
+Content before
+\end_layout
+
+\begin_layout LyX-Code
+
+\change_inserted 1075283030 1597699357
+<paratag>Contents of the paragraph.</paratag>
+\end_layout
+
+\begin_layout LyX-Code
+
+\change_inserted 1075283030 1597699231
+Content after
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted 1075283030 1597699343
+\begin_inset Quotes eld
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699307
+inline
+\end_layout
+
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+: the opening and closing tags are on the same line as the rest of the content.
+ No line feeds are output.
+ Typical elements are fonts.
+ For instance: 
+\end_layout
+
+\begin_layout LyX-Code
+
+\change_inserted 1075283030 1597699585
+Content before<inlinetag>Contents of the paragraph.</inlinetag>Content after
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted 1075283030 1597699585
+The default value is always 
+\begin_inset Quotes eld
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699585
+block
+\end_layout
+
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+.
 \change_unchanged
 
 \end_layout
@@ -28158,6 +28415,52 @@ NONE
  This parameter only makes sense when itemising layouts are used, such as
  lists.
  
+\change_inserted 1075283030 1597699848
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 1075283030 1597699866
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699853
+DocBookItemInnerTagType
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699866
+block, paragraph, inline
+\end_layout
+
+\end_inset
+
+] The new-line policy for this tag, see Section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:DocBook-New-line-policy"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+ for the details.
+ 
 \change_unchanged
 
 \end_layout
@@ -28277,6 +28580,52 @@ itemlabeltag
  This parameter only makes sense when itemising layouts are used with a
  notion of labels, such as definition lists.
  
+\change_inserted 1075283030 1597699874
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 1075283030 1597699874
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699880
+DocBookItemLabelTagType
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699874
+block, paragraph, inline
+\end_layout
+
+\end_inset
+
+] The new-line policy for this tag, see Section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:DocBook-New-line-policy"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+ for the details.
+ 
 \change_unchanged
 
 \end_layout
@@ -28352,6 +28701,54 @@ NONE
  This parameter only makes sense when itemising layouts are used, such as
  lists.
  
+\change_inserted 1075283030 1597699890
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 1075283030 1597699890
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699890
+DocBookItemTagType
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699890
+block, paragraph, inline
+\end_layout
+
+\end_inset
+
+] The new-line policy for this tag, see Section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:DocBook-New-line-policy"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+ for the details.
+ 
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
@@ -28487,6 +28884,52 @@ NONE
  This parameter only makes sense when itemising layouts are used, such as
  lists.
  
+\change_inserted 1075283030 1597699897
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 1075283030 1597699897
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699900
+DocBookItemWrapperTagType
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699897
+block, paragraph, inline
+\end_layout
+
+\end_inset
+
+] The new-line policy for this tag, see Section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:DocBook-New-line-policy"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+ for the details.
+ 
 \change_unchanged
 
 \end_layout
@@ -28618,6 +29061,54 @@ NONE
 
 , indicating that there is no inner tag: content is directly output without
  it.
+\change_inserted 1075283030 1597699904
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 1075283030 1597699904
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699904
+DocBookInnerTagType
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699904
+block, paragraph, inline
+\end_layout
+
+\end_inset
+
+] The new-line policy for this tag, see Section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:DocBook-New-line-policy"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+ for the details.
+ 
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
@@ -28668,7 +29159,11 @@ section
 \end_inset
 
 , and is only overridden when DocBook uses something else for sectioning
- (parts and chapters of a book).
+ (
+\change_inserted 1075283030 1597699921
+typically, 
+\change_inserted -970929547 1515110753
+parts and chapters of a book).
  
 \change_unchanged
 
@@ -28729,6 +29224,54 @@ tag
  in the example above.
  The default is the name of the float and always needs to be changed, as
  DocBook provides no generic inset tag.
+\change_inserted 1075283030 1597699924
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 1075283030 1597699924
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699924
+DocBookTagType
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699924
+block, paragraph, inline
+\end_layout
+
+\end_inset
+
+] The new-line policy for this tag, see Section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:DocBook-New-line-policy"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+ for the details.
+ 
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
@@ -28858,7 +29401,53 @@ NONE
 
 , indicating that there is no wrapper tag: tag and content are directly
  output without it.
-\change_deleted -970929547 1515111523
+\change_inserted 1075283030 1597699929
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 1075283030 1597699929
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699932
+DocBookWrapperTagType
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597699929
+block, paragraph, inline
+\end_layout
+
+\end_inset
+
+] The new-line policy for this tag, see Section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:DocBook-New-line-policy"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+ for the details.
+ 
+\change_unchanged
 
 \end_layout
 
@@ -29024,9 +29613,59 @@ Bibliography formatting
 
 \begin_layout Standard
 
+\change_deleted 1075283030 1597699984
+The 
+\change_inserted 1075283030 1597699985
+Included 
+\change_inserted -970929547 1515110187
+bibliograph
+\change_deleted 1075283030 1597699987
+y
+\change_inserted 1075283030 1597699987
+ies
+\change_inserted -970929547 1515110187
+ cannot be formatted: all fields are always output in the database-like
+ DocBook format (equivalent to a BibTeX file)
+\change_inserted 1075283030 1597700117
+, using the 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597700120
+biblioentry
+\end_layout
+
+\end_inset
+
+ tag
 \change_inserted -970929547 1515110187
-The bibliography cannot be formatted: all fields are always output in the
- database-like DocBook format (equivalent to a BibTeX file).
+.
+\change_inserted 1075283030 1597700092
+
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted 1075283030 1597700112
+When the bibliographic entries are manually inserted into the LyX document
+ as Bibliography Items, the user deals with formatting themself: there is
+ no attempt of parsing what the user wrote, the string is directly used
+ (with the 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1075283030 1597700076
+bibliomixed
+\end_layout
+
+\end_inset
+
+ tag).
+ 
 \change_unchanged
 
 \end_layout
diff --git a/lib/generate_contributions.py b/lib/generate_contributions.py
index 4e3e191..e864ebd 100755
--- a/lib/generate_contributions.py
+++ b/lib/generate_contributions.py
@@ -650,7 +650,7 @@ contributors = [
                  "Re: Patches to improve compatibility with modern C++ standard",
                  "m=158862338815864",
                  "4 May 2020",
-                 u"Windows compatibility patches, Docbook backend"),
+                 u"Windows compatibility patches, DocBook backend"),
 
      contributor(u"Matthias Kalle Dalheimer",
                  "kalle () kdab ! net",

commit f681e317d17166eaa0abf6e866521a1b52e46824
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Aug 17 23:06:26 2020 +0200

    DocBook: define new arguments in layouts to configure new-line behaviour.

diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 2bb62e3..7cf2332 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -11,7 +11,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 83
+currentFormat = 84
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -284,6 +284,11 @@ currentFormat = 83
 # Incremented to format 83, 2 August 2020 by dourouc05
 # New tags DocBookWrapperMergeWithPrevious and DocBookAbstract
 
+# Incremented to format 84, 17 August 2020 by tcuvelier
+# New tags DocBookTagType, DocBookWrapperTagTagType,
+# DocBookItemWrapperTagTagType, DocBookItemTagTagType,
+# DocBookLabelTag
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
diff --git a/src/Floating.cpp b/src/Floating.cpp
index ebd1e41..d44afc3 100644
--- a/src/Floating.cpp
+++ b/src/Floating.cpp
@@ -31,8 +31,8 @@ Floating::Floating(string const & type, string const & placement,
 		   string const & refPrefix, std::string const & allowedplacement,
 		   string const & htmlTag, string const & htmlAttrib,
 		   docstring const & htmlStyle, string const & docbookTag,
-		   string const & docbookAttr, string const & required,
-		   bool usesfloat, bool ispredefined,
+		   string const & docbookAttr, string const & docbookTagType,
+           string const & required, bool usesfloat, bool ispredefined,
 		   bool allowswide, bool allowssideways)
 	: floattype_(type), placement_(placement), ext_(ext), within_(within),
 	  style_(style), name_(name), listname_(listName), listcommand_(listCmd),
@@ -40,7 +40,8 @@ Floating::Floating(string const & type, string const & placement,
 	  usesfloatpkg_(usesfloat), ispredefined_(ispredefined),
 	  allowswide_(allowswide), allowssideways_(allowssideways),
 	  html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle),
-	  docbook_tag_(docbookTag), docbook_attr_(docbookAttr)
+	  docbook_tag_(docbookTag), docbook_attr_(docbookAttr),
+	  docbook_tag_type_(docbookTagType)
 {}
 
 
@@ -90,20 +91,30 @@ string const & Floating::docbookAttr() const
 
 string const & Floating::docbookTag(bool hasTitle) const
 {
-	docbook_tag_ = "";
-	if (floattype_ == "figure") {
-		docbook_tag_ = hasTitle ? "figure" : "informalfigure";
-	} else if (floattype_ == "table") {
-		docbook_tag_ = hasTitle ? "table" : "informaltable";
-	} else if (floattype_ == "algorithm") {
-		// TODO: no good translation for now! Figures are the closest match, as they can contain text.
-		// Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
-		docbook_tag_ = "figure";
+	if (docbook_tag_.empty()) {
+		docbook_tag_ = "";
+		if (floattype_ == "figure") {
+			docbook_tag_ = hasTitle ? "figure" : "informalfigure";
+		} else if (floattype_ == "table") {
+			docbook_tag_ = hasTitle ? "table" : "informaltable";
+		} else if (floattype_ == "algorithm") {
+			// TODO: no good translation for now! Figures are the closest match, as they can contain text.
+			// Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
+			docbook_tag_ = "figure";
+		}
 	}
 	return docbook_tag_;
 }
 
 
+string const & Floating::docbookTagType() const
+{
+	if (docbook_tag_type_ != "block" && docbook_tag_type_ != "paragraph" && docbook_tag_type_ != "inline")
+		docbook_tag_type_ = "block";
+	return docbook_tag_type_;
+}
+
+
 string const & Floating::docbookCaption() const
 {
 	docbook_caption_ = "";
diff --git a/src/Floating.h b/src/Floating.h
index d10694f..5cfea08 100644
--- a/src/Floating.h
+++ b/src/Floating.h
@@ -38,8 +38,9 @@ public:
 		 std::string const & refPrefix, std::string const & allowedplacement,
 		 std::string const & htmlType, std::string const & htmlClass,
 		 docstring const & htmlStyle, std::string const & docbookTag,
-		 std::string const & docbookAttr, std::string const & required,
-		 bool usesfloat, bool isprefined, bool allowswide, bool allowssideways);
+		 std::string const & docbookAttr, std::string const & docbookTagType,
+		 std::string const & required, bool usesfloat, bool isprefined,
+		 bool allowswide, bool allowssideways);
 	///
 	std::string const & floattype() const { return floattype_; }
 	///
@@ -84,6 +85,8 @@ public:
 	///
 	std::string const & docbookAttr() const;
 	///
+	std::string const & docbookTagType() const;
+	///
 	std::string const & docbookCaption() const;
 private:
 	///
@@ -115,9 +118,9 @@ private:
 	///
 	bool ispredefined_;
 	///
-	bool  allowswide_;
+	bool allowswide_;
 	///
-	bool  allowssideways_;
+	bool allowssideways_;
 	///
 	mutable std::string html_tag_;
 	///
@@ -132,6 +135,8 @@ private:
 	mutable std::string docbook_caption_;
 	/// caption tag (mostly, either caption or title)
 	std::string docbook_attr_;
+	/// DocBook tag type (block, paragraph, inline)
+	mutable std::string docbook_tag_type_;
 };
 
 
diff --git a/src/Layout.cpp b/src/Layout.cpp
index 5047506..102410d 100644
--- a/src/Layout.cpp
+++ b/src/Layout.cpp
@@ -106,20 +106,26 @@ enum LayoutTags {
 	LT_HTMLFORCECSS,
 	LT_DOCBOOKTAG,
 	LT_DOCBOOKATTR,
+	LT_DOCBOOKTAGTYPE,
 	LT_DOCBOOKININFO,
 	LT_DOCBOOKABSTRACT,
 	LT_DOCBOOKWRAPPERTAG,
 	LT_DOCBOOKWRAPPERATTR,
+	LT_DOCBOOKWRAPPERTAGTYPE,
 	LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS,
 	LT_DOCBOOKSECTIONTAG,
 	LT_DOCBOOKITEMWRAPPERTAG,
 	LT_DOCBOOKITEMWRAPPERATTR,
+	LT_DOCBOOKITEMWRAPPERTAGTYPE,
 	LT_DOCBOOKITEMTAG,
 	LT_DOCBOOKITEMATTR,
+	LT_DOCBOOKITEMTAGTYPE,
 	LT_DOCBOOKITEMLABELTAG,
 	LT_DOCBOOKITEMLABELATTR,
+	LT_DOCBOOKITEMLABELTAGTYPE,
 	LT_DOCBOOKITEMINNERTAG,
 	LT_DOCBOOKITEMINNERATTR,
+	LT_DOCBOOKITEMINNERTAGTYPE,
 	LT_DOCBOOKFORCEABSTRACTTAG,
 	LT_INPREAMBLE,
 	LT_HTMLTITLE,
@@ -223,23 +229,29 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
 		{ "commanddepth",   LT_COMMANDDEPTH },
 		{ "copystyle",      LT_COPYSTYLE },
 		{ "dependson",      LT_DEPENDSON },
-		{ "docbookabstract",         LT_DOCBOOKABSTRACT },
-		{ "docbookattr",             LT_DOCBOOKATTR },
-		{ "docbookforceabstracttag", LT_DOCBOOKFORCEABSTRACTTAG },
-		{ "docbookininfo",           LT_DOCBOOKININFO },
-		{ "docbookitemattr",         LT_DOCBOOKITEMATTR },
-		{ "docbookiteminnerattr",    LT_DOCBOOKITEMINNERATTR },
-		{ "docbookiteminnertag",     LT_DOCBOOKITEMINNERTAG },
-		{ "docbookitemlabelattr",    LT_DOCBOOKITEMLABELATTR },
-		{ "docbookitemlabeltag",     LT_DOCBOOKITEMLABELTAG },
-		{ "docbookitemtag",          LT_DOCBOOKITEMTAG },
-		{ "docbookitemwrapperattr",  LT_DOCBOOKITEMWRAPPERATTR },
-		{ "docbookitemwrappertag",   LT_DOCBOOKITEMWRAPPERTAG },
-		{ "docbooksectiontag",       LT_DOCBOOKSECTIONTAG },
-		{ "docbooktag",              LT_DOCBOOKTAG },
-		{ "docbookwrapperattr",      LT_DOCBOOKWRAPPERATTR },
+		{ "docbookabstract",           LT_DOCBOOKABSTRACT },
+		{ "docbookattr",               LT_DOCBOOKATTR },
+		{ "docbookforceabstracttag",   LT_DOCBOOKFORCEABSTRACTTAG },
+		{ "docbookininfo",             LT_DOCBOOKININFO },
+		{ "docbookitemattr",           LT_DOCBOOKITEMATTR },
+		{ "docbookiteminnerattr",      LT_DOCBOOKITEMINNERATTR },
+		{ "docbookiteminnertag",       LT_DOCBOOKITEMINNERTAG },
+		{ "docbookiteminnertagtype",   LT_DOCBOOKITEMINNERTAGTYPE },
+		{ "docbookitemlabelattr",      LT_DOCBOOKITEMLABELATTR },
+		{ "docbookitemlabeltag",       LT_DOCBOOKITEMLABELTAG },
+		{ "docbookitemlabeltagtype",   LT_DOCBOOKITEMLABELTAGTYPE },
+		{ "docbookitemtag",            LT_DOCBOOKITEMTAG },
+		{ "docbookitemtagtype",        LT_DOCBOOKITEMTAGTYPE },
+		{ "docbookitemwrapperattr",    LT_DOCBOOKITEMWRAPPERATTR },
+		{ "docbookitemwrappertag",     LT_DOCBOOKITEMWRAPPERTAG },
+		{ "docbookitemwrappertagtype", LT_DOCBOOKITEMWRAPPERTAGTYPE },
+		{ "docbooksectiontag",         LT_DOCBOOKSECTIONTAG },
+		{ "docbooktag",                LT_DOCBOOKTAG },
+		{ "docbooktagtype",            LT_DOCBOOKTAGTYPE },
+		{ "docbookwrapperattr",        LT_DOCBOOKWRAPPERATTR },
 		{ "docbookwrappermergewithprevious", LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS },
-		{ "docbookwrappertag",       LT_DOCBOOKWRAPPERTAG },
+		{ "docbookwrappertag",         LT_DOCBOOKWRAPPERTAG },
+		{ "docbookwrappertagtype",     LT_DOCBOOKWRAPPERTAGTYPE },
 		{ "end",            LT_END },
 		{ "endlabelstring", LT_ENDLABELSTRING },
 		{ "endlabeltype",   LT_ENDLABELTYPE },
@@ -733,6 +745,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
 			lex >> docbookattr_;
 			break;
 
+		case LT_DOCBOOKTAGTYPE:
+			lex >> docbooktagtype_;
+			break;
+
 		case LT_DOCBOOKFORCEABSTRACTTAG:
 			lex >> docbookforceabstracttag_;
 			break;
@@ -753,6 +769,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
 			lex >> docbookwrapperattr_;
 			break;
 
+		case LT_DOCBOOKWRAPPERTAGTYPE:
+			lex >> docbookwrappertagtype_;
+			break;
+
 		case LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS:
 			lex >> docbookwrappermergewithprevious_;
 			break;
@@ -769,6 +789,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
 			lex >> docbookitemwrapperattr_;
 			break;
 
+		case LT_DOCBOOKITEMWRAPPERTAGTYPE:
+			lex >> docbookitemwrappertagtype_;
+			break;
+
 		case LT_DOCBOOKITEMTAG:
 			lex >> docbookitemtag_;
 			break;
@@ -777,6 +801,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
 			lex >> docbookitemattr_;
 			break;
 
+		case LT_DOCBOOKITEMTAGTYPE:
+			lex >> docbookitemtagtype_;
+			break;
+
 		case LT_DOCBOOKITEMLABELTAG:
 			lex >> docbookitemlabeltag_;
 			break;
@@ -785,6 +813,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
 			lex >> docbookitemlabelattr_;
 			break;
 
+		case LT_DOCBOOKITEMLABELTAGTYPE:
+			lex >> docbookitemlabeltagtype_;
+			break;
+
 		case LT_DOCBOOKITEMINNERTAG:
 			lex >> docbookiteminnertag_;
 			break;
@@ -793,6 +825,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
 			lex >> docbookiteminnerattr_;
 			break;
 
+		case LT_DOCBOOKITEMINNERTAGTYPE:
+			lex >> docbookiteminnertagtype_;
+			break;
+
 		case LT_SPELLCHECK:
 			lex >> spellcheck;
 			break;
@@ -1608,6 +1644,8 @@ void Layout::write(ostream & os) const
 		os << "\tDocBookTag " << docbooktag_ << '\n';
 	if(!docbookattr_.empty())
 		os << "\tDocBookAttr " << docbookattr_ << '\n';
+	if(!docbooktagtype_.empty())
+		os << "\tDocBookTagType " << docbooktagtype_ << '\n';
 	if(!docbookininfo_.empty())
 		os << "\tDocBookInInfo " << docbookininfo_ << '\n';
 	os << "\tDocBookAbstract " << docbookabstract_ << '\n';
@@ -1615,25 +1653,35 @@ void Layout::write(ostream & os) const
 		os << "\tDocBookWrapperTag " << docbookwrappertag_ << '\n';
 	if(!docbookwrapperattr_.empty())
 		os << "\tDocBookWrapperAttr " << docbookwrapperattr_ << '\n';
+	if(!docbookwrappertagtype_.empty())
+		os << "\tDocBookWrapperTagType " << docbookwrappertagtype_ << '\n';
 	if(!docbooksectiontag_.empty())
 		os << "\tDocBookSectionTag " << docbooksectiontag_ << '\n';
 	if(!docbookitemtag_.empty())
 		os << "\tDocBookItemTag " << docbookitemtag_ << '\n';
 	if(!docbookitemattr_.empty())
 		os << "\tDocBookItemAttr " << docbookitemattr_ << '\n';
+	if(!docbookitemtagtype_.empty())
+		os << "\tDocBookItemTagType " << docbookitemtagtype_ << '\n';
 	if(!docbookitemwrappertag_.empty())
 		os << "\tDocBookItemWrapperTag " << docbookitemwrappertag_ << '\n';
 	if(!docbookitemwrapperattr_.empty())
 		os << "\tDocBookItemWrapperAttr " << docbookitemwrapperattr_ << '\n';
+	if(!docbookitemwrappertagtype_.empty())
+		os << "\tDocBookItemWrapperTagType " << docbookitemwrappertagtype_ << '\n';
 	os << "\tDocBookItemWrapperMergeWithPrevious " << docbookwrappermergewithprevious_ << '\n';
 	if(!docbookitemlabeltag_.empty())
 		os << "\tDocBookItemLabelTag " << docbookitemlabeltag_ << '\n';
 	if(!docbookitemlabelattr_.empty())
 		os << "\tDocBookItemLabelAttr " << docbookitemlabelattr_ << '\n';
+	if(!docbookitemlabeltagtype_.empty())
+		os << "\tDocBookItemLabelTagType " << docbookitemlabeltagtype_ << '\n';
 	if(!docbookiteminnertag_.empty())
 		os << "\tDocBookItemInnerTag " << docbookiteminnertag_ << '\n';
 	if(!docbookiteminnerattr_.empty())
 		os << "\tDocBookItemInnerAttr " << docbookiteminnerattr_ << '\n';
+	if(!docbookiteminnertagtype_.empty())
+		os << "\tDocBookItemInnerTagType " << docbookiteminnertagtype_ << '\n';
 	if(!docbookforceabstracttag_.empty())
 		os << "\tDocBookForceAbstractTag " << docbookforceabstracttag_ << '\n';
 	os << "\tSpellcheck " << spellcheck << "\n"
@@ -1786,9 +1834,12 @@ string Layout::defaultCSSClass() const
 
 string const & Layout::docbooktag() const
 {
-	// No sensible default value, unhappily...
-	if (docbooktag_.empty())
-		docbooktag_ = to_utf8(name_);
+	if (docbooktag_.empty()) {
+		if (to_ascii(name_) == "Plain Layout")
+			docbooktag_ = "para";
+		else // No sensible default value, unhappily...
+			docbooktag_ = to_utf8(name_);
+	}
 	return docbooktag_;
 }
 
@@ -1800,6 +1851,20 @@ string const & Layout::docbookattr() const
 }
 
 
+bool isValidTagType(std::string type)
+{
+	return !(type.empty() || (type != "block" && type != "paragraph" && type != "inline"));
+}
+
+
+string const & Layout::docbooktagtype() const
+{
+	if (!isValidTagType(docbooktagtype_))
+		docbooktagtype_ = "block";
+	return docbooktagtype_;
+}
+
+
 string const & Layout::docbookininfo() const
 {
 	// Indeed, a trilean. Only titles should be "maybe": otherwise, metadata is "always", content is "never". 
@@ -1823,6 +1888,14 @@ string const & Layout::docbookwrapperattr() const
 }
 
 
+string const & Layout::docbookwrappertagtype() const
+{
+	if (!isValidTagType(docbookwrappertagtype_))
+		docbookwrappertagtype_ = "block";
+	return docbookwrappertagtype_;
+}
+
+
 string const & Layout::docbooksectiontag() const
 {
 	if (docbooksectiontag_.empty())
@@ -1845,9 +1918,19 @@ string const & Layout::docbookitemwrapperattr() const
 }
 
 
+string const & Layout::docbookitemwrappertagtype() const
+{
+	if (!isValidTagType(docbookitemwrappertagtype_))
+		docbookitemwrappertagtype_ = "block";
+	return docbookitemwrappertagtype_;
+}
+
+
 string const & Layout::docbookitemtag() const
 {
-    return docbookitemtag_;
+	if (docbookitemtag_.empty())
+		docbookitemtag_ = "NONE";
+	return docbookitemtag_;
 }
 
 
@@ -1857,6 +1940,14 @@ string const & Layout::docbookitemattr() const
 }
 
 
+string const & Layout::docbookitemtagtype() const
+{
+	if (!isValidTagType(docbookitemtagtype_))
+		docbookitemtagtype_ = "block";
+	return docbookitemtagtype_;
+}
+
+
 string const & Layout::docbookitemlabeltag() const
 {
 	if (docbookitemlabeltag_.empty())
@@ -1871,6 +1962,14 @@ string const & Layout::docbookitemlabelattr() const
 }
 
 
+string const & Layout::docbookitemlabeltagtype() const
+{
+	if (!isValidTagType(docbookitemlabeltagtype_))
+		docbookitemlabeltagtype_ = "block";
+	return docbookitemlabeltagtype_;
+}
+
+
 string const & Layout::docbookiteminnertag() const
 {
 	if (docbookiteminnertag_.empty())
@@ -1885,6 +1984,14 @@ string const & Layout::docbookiteminnerattr() const
 }
 
 
+string const & Layout::docbookiteminnertagtype() const
+{
+	if (!isValidTagType(docbookiteminnertagtype_))
+		docbookiteminnertagtype_ = "block";
+	return docbookiteminnertagtype_;
+}
+
+
 std::string const & Layout::docbookforceabstracttag() const
 {
 	if (docbookforceabstracttag_.empty())
diff --git a/src/Layout.h b/src/Layout.h
index a894142..14784a2 100644
--- a/src/Layout.h
+++ b/src/Layout.h
@@ -197,6 +197,8 @@ public:
 	///
 	std::string const & docbookattr() const;
 	///
+	std::string const & docbooktagtype() const;
+	///
 	std::string const & docbookininfo() const;
 	///
 	bool docbookabstract() const { return docbookabstract_; }
@@ -205,6 +207,8 @@ public:
 	///
 	std::string const & docbookwrapperattr() const;
 	///
+	std::string const & docbookwrappertagtype() const;
+	///
 	bool docbookwrappermergewithprevious() const { return docbookwrappermergewithprevious_; }
 	///
 	std::string const & docbooksectiontag() const;
@@ -213,18 +217,26 @@ public:
 	///
 	std::string const & docbookitemwrapperattr() const;
 	///
+	std::string const & docbookitemwrappertagtype() const;
+	///
 	std::string const & docbookitemlabeltag() const;
 	///
 	std::string const & docbookitemlabelattr() const;
 	///
+	std::string const & docbookitemlabeltagtype() const;
+	///
 	std::string const & docbookiteminnertag() const;
 	///
 	std::string const & docbookiteminnerattr() const;
 	///
+	std::string const & docbookiteminnertagtype() const;
+	///
 	std::string const & docbookitemtag() const;
 	///
 	std::string const & docbookitemattr() const;
 	///
+	std::string const & docbookitemtagtype() const;
+	///
 	std::string const & docbookforceabstracttag() const;
 	///
 	bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
@@ -495,27 +507,39 @@ private:
 	mutable std::string docbooktag_;
 	/// Roles to add to docbooktag_, if any (default: none).
 	mutable std::string docbookattr_;
+	/// DocBook tag type corresponding to this layout (block, paragraph, or inline; default: block).
+	mutable std::string docbooktagtype_;
 	/// DocBook tag corresponding to this item (mainly for lists).
 	mutable std::string docbookitemtag_;
 	/// Roles to add to docbookitemtag_, if any (default: none).
 	mutable std::string docbookitemattr_;
+	/// DocBook tag type corresponding to this item (block, paragraph, or inline; default: block).
+	mutable std::string docbookitemtagtype_;
 	/// DocBook tag corresponding to the wrapper around an item (mainly for lists).
 	mutable std::string docbookitemwrappertag_;
 	/// Roles to add to docbookitemwrappertag_, if any (default: none).
 	mutable std::string docbookitemwrapperattr_;
-	/// DocBook tag corresponding to this label (only for description lists;
+	/// DocBook tag type corresponding to the wrapper around an item (block, paragraph, or inline; default: block).
+	mutable std::string docbookitemwrappertagtype_;
+	/// DocBook tag corresponding to this label (mostly for description lists;
 	/// labels in the common sense do not exist with DocBook).
 	mutable std::string docbookitemlabeltag_;
 	/// Roles to add to docbooklabeltag_, if any (default: none).
 	mutable std::string docbookitemlabelattr_;
+	/// DocBook tag corresponding to this label (block, paragraph, or inline; default: block).
+	mutable std::string docbookitemlabeltagtype_;
 	/// DocBook tag to add within the item, around its direct content (mainly for lists).
 	mutable std::string docbookiteminnertag_;
 	/// Roles to add to docbookiteminnertag_, if any (default: none).
 	mutable std::string docbookiteminnerattr_;
+	/// DocBook tag to add within the item, around its direct content (block, paragraph, or inline; default: block).
+	mutable std::string docbookiteminnertagtype_;
 	/// DocBook tag corresponding to this wrapper around the main tag.
 	mutable std::string docbookwrappertag_;
 	/// Roles to add to docbookwrappertag_, if any (default: none).
 	mutable std::string docbookwrapperattr_;
+	/// DocBook tag corresponding to this wrapper around the main tag (block, paragraph, or inline; default: block).
+	mutable std::string docbookwrappertagtype_;
 	/// Whether this wrapper tag may be merged with the previously opened wrapper tag.
 	bool docbookwrappermergewithprevious_;
 	/// Outer tag for this section, only if this layout represent a sectionning item, including chapters
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index 79cdabd..e413403 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -62,7 +62,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 83; // tcuvelier: DocBookWrapperMergeWithPrevious.
+int const LAYOUT_FORMAT = 84; // tcuvelier: DocBook*TagType.
 
 
 // Layout format for the current lyx file format. Controls which format is
@@ -1378,6 +1378,7 @@ bool TextClass::readFloat(Lexer & lexrc)
 		FT_HTMLTAG,
 		FT_DOCBOOKATTR,
 		FT_DOCBOOKTAG,
+		FT_DOCBOOKTAGTYPE,
 		FT_LISTCOMMAND,
 		FT_REFPREFIX,
 		FT_ALLOWED_PLACEMENT,
@@ -1393,6 +1394,7 @@ bool TextClass::readFloat(Lexer & lexrc)
 		{ "allowswide", FT_ALLOWS_WIDE },
 		{ "docbookattr", FT_DOCBOOKATTR },
 		{ "docbooktag", FT_DOCBOOKTAG },
+		{ "docbooktagtype", FT_DOCBOOKTAGTYPE },
 		{ "end", FT_END },
 		{ "extension", FT_EXT },
 		{ "guiname", FT_NAME },
@@ -1419,6 +1421,7 @@ bool TextClass::readFloat(Lexer & lexrc)
 	string htmltag;
 	string docbookattr;
 	string docbooktag;
+	string docbooktagtype;
 	string listname;
 	string listcommand;
 	string name;
@@ -1540,6 +1543,10 @@ bool TextClass::readFloat(Lexer & lexrc)
 			lexrc.next();
 			docbooktag = lexrc.getString();
 			break;
+		case FT_DOCBOOKTAGTYPE:
+			lexrc.next();
+			docbooktagtype = lexrc.getString();
+			break;
 		case FT_END:
 			getout = true;
 			break;
@@ -1568,8 +1575,8 @@ bool TextClass::readFloat(Lexer & lexrc)
 		Floating fl(type, placement, ext, within, style, name,
 			listname, listcommand, refprefix, allowed_placement,
 			htmltag, htmlattr, htmlstyle, docbooktag, docbookattr,
-			required, usesfloat, ispredefined, allowswide,
-			allowssideways);
+			docbooktagtype, required, usesfloat, ispredefined,
+	        allowswide, allowssideways);
 		floatlist_.newFloat(fl);
 		// each float has its own counter
 		counters_.newCounter(from_ascii(type), from_ascii(within),

-----------------------------------------------------------------------

Summary of changes:
 lib/scripts/layout2layout.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
Repository for new features


More information about the lyx-cvs mailing list