DocBook: specific fix for Localization_Test.lyx.

In one paragraph, there was both a float and a list of floats in a paragraph: the list of floats has no DocBook output, so that there should be no surrounding <para>.
This commit is contained in:
Thibaut Cuvelier 2020-11-15 19:04:21 +01:00
parent 0ed820fa0b
commit dc94abf039
3 changed files with 276 additions and 17 deletions

View File

@ -0,0 +1,220 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 599
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\use_default_options false
\begin_modules
theorems-ams
theorems-ams-extended
linguistics
\end_modules
\maintain_unincluded_children no
\language english
\language_package default
\inputencoding utf8
\fontencoding auto
\font_roman "lmodern" "default"
\font_sans "default" "default"
\font_typewriter "default" "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 false
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref 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
\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 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
\SpecialChar LyX
localization test
\end_layout
\begin_layout Section
Test of insets and listings
\end_layout
\begin_layout Standard
\begin_inset Float algorithm
placement H
alignment document
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
hhh
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset FloatList algorithm
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Float tableau
placement H
alignment document
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
fggf
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset FloatList tableau
\end_inset
\end_layout
\begin_layout Standard
\begin_inset listings
lstparams "float,language={C++}"
inline false
status open
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
ccc
\end_layout
\end_inset
while(true);
\end_layout
\end_inset
\begin_inset CommandInset toc
LatexCommand lstlistoflistings
\end_inset
\end_layout
\begin_layout Standard
\begin_inset CommandInset nomenclature
LatexCommand nomenclature
symbol "x"
description "dfadsf13"
literal "false"
\end_inset
\end_layout
\begin_layout Standard
\begin_inset CommandInset nomencl_print
LatexCommand printnomenclature
set_width "auto"
\end_inset
\end_layout
\end_body
\end_document

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This DocBook file was created by LyX 2.4.0dev
See http://www.lyx.org/ for more information -->
<article xml:lang="en_US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2">
<title>LyX localization test</title>
<section>
<title>Test of insets and listings</title>
<figure>
<title>hhh</title>
</figure>
<table>
<caption>fggf</caption>
</table>
<figure type='listing'>
<title>ccc</title>
<programlisting language="C++">while(true);</programlisting>
</figure>
<para><glossterm linkend="nomenx">x</glossterm></para>
<glossary>
<title>Nomenclature</title>
<glossentry xml:id="nomenx">
<glossterm>x</glossterm>
<glossdef>
<para>dfadsf13</para>
</glossdef>
</glossentry>
</glossary>
</section>
</article>

View File

@ -450,46 +450,55 @@ void makeParagraph(
}
size_t nInsets = std::distance(par->insetList().begin(), par->insetList().end());
auto parSize = (size_t) par->size();
auto isLyxCodeToIgnore = [](InsetCode x) { return x == TOC_CODE; }; // If this LyX code does not produce any output,
// it can be safely ignored in the following checks: if this thing is present in the paragraph, it has no impact
// on the definition of the special case (i.e. whether or not a <para> tag should be output).
// TODO: if a paragraph *only* contains floats, listings, bibliographies, etc., should this be considered as a
// special case? If so, the code could be largely simplifies (all the calls to all_of, basically) and optimised
// at the compilation stage.
// 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).
// Exception: any case that generates an <inlineequation> must still get a paragraph to be valid.
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset && inset.inset->asInsetMath() && inset.inset->asInsetMath()->getType() != hullSimple;
});
// Tables do not deserve their own paragraphs (DocBook allows them outside paragraphs).
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset->lyxCode() == TABULAR_CODE;
special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [isLyxCodeToIgnore](InsetList::Element inset) {
return inset.inset->lyxCode() == TABULAR_CODE || isLyxCodeToIgnore(inset.inset->lyxCode());
});
// Floats cannot be in paragraphs.
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset->lyxCode() == FLOAT_CODE;
special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [isLyxCodeToIgnore](InsetList::Element inset) {
return inset.inset->lyxCode() == FLOAT_CODE || isLyxCodeToIgnore(inset.inset->lyxCode());
});
// Bibliographies cannot be in paragraphs. Bibitems should still be handled as paragraphs, though
// (see makeParagraphBibliography).
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset->lyxCode() == BIBTEX_CODE;
special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [isLyxCodeToIgnore](InsetList::Element inset) {
return inset.inset->lyxCode() == BIBTEX_CODE || isLyxCodeToIgnore(inset.inset->lyxCode());
});
// ERTs are in comments, not paragraphs.
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset->lyxCode() == ERT_CODE;
special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [isLyxCodeToIgnore](InsetList::Element inset) {
return inset.inset->lyxCode() == ERT_CODE || isLyxCodeToIgnore(inset.inset->lyxCode());
});
// Listings should not get into their own paragraph.
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset->lyxCode() == LISTINGS_CODE;
special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [isLyxCodeToIgnore](InsetList::Element inset) {
return inset.inset->lyxCode() == LISTINGS_CODE || isLyxCodeToIgnore(inset.inset->lyxCode());
});
// Boxes cannot get into their own paragraph.
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset->lyxCode() == BOX_CODE;
special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [isLyxCodeToIgnore](InsetList::Element inset) {
return inset.inset->lyxCode() == BOX_CODE || isLyxCodeToIgnore(inset.inset->lyxCode());
});
// Includes should not have a paragraph.
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset->lyxCode() == INCLUDE_CODE;
special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [isLyxCodeToIgnore](InsetList::Element inset) {
return inset.inset->lyxCode() == INCLUDE_CODE || isLyxCodeToIgnore(inset.inset->lyxCode());
});
// Glossaries should not have a paragraph.
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset->lyxCode() == NOMENCL_PRINT_CODE;
special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [isLyxCodeToIgnore](InsetList::Element inset) {
return inset.inset->lyxCode() == NOMENCL_PRINT_CODE || isLyxCodeToIgnore(inset.inset->lyxCode());
});
bool const open_par = runparams.docbook_make_pars