DocBook: for empty figures, output a message.

This ensures that this part of the DocBook file is valid.
This commit is contained in:
Thibaut Cuvelier 2020-11-27 05:19:27 +01:00
parent 185a62e695
commit 3f07ae9083
2 changed files with 26 additions and 4 deletions

View File

@ -498,7 +498,7 @@ export/examples/(es|fr)/Modules/Linguistics_docbook5
export/examples/ko/cjk-ko-doc_docbook5
# - Metadata in abstract paragraph.
export/templates/Articles/Springers_Global_Journal_Template_%28V._3%29_docbook5
# - Sweave impossible to implement. Document irremediably wrong (no .bib file, still referenced in the text).
# - Sweave impossible to implement. Broken references (no .bib file, still referenced in the text).
export/templates/Articles/R_Journal_docbook5
# - Forbidden inlines, equation in formatting, broken references, float in paragraphs, videos.
export/templates/Articles/REVTeX_%28V._4.1%29_docbook5

View File

@ -731,6 +731,11 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
if (ftype.docbookFloatType() == "table")
rpNoTitle.docbook_in_table = true;
// Generate the contents of the float (to check for emptiness).
odocstringstream os2;
XMLStream xs2(os2);
thisFloat->InsetText::docbook(xs, rpNoTitle);
// Organisation: <float> <title if any/> <contents without title/> </float>.
docstring attr = docstring();
if (label)
@ -749,7 +754,24 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
xs << xml::EndTag(titleTag);
xs << xml::CR();
}
thisFloat->InsetText::docbook(xs, rpNoTitle);
if (!os2.str().empty()) {
xs << XMLStream::ESCAPE_NONE << os2.str();
} else {
xs << xml::StartTag("mediaobject");
xs << xml::CR();
xs << xml::StartTag("textobject");
xs << xml::CR();
xs << xml::StartTag("phrase");
xs << "This figure is empty.";
xs << xml::EndTag("phrase");
xs << xml::CR();
xs << xml::EndTag("textobject");
xs << xml::CR();
xs << xml::EndTag("mediaobject");
xs << xml::CR();
}
xs << xml::EndTag(ftype.docbookTag(caption != nullptr));
xs << xml::CR();
}
@ -777,8 +799,8 @@ void InsetFloat::docbook(XMLStream & xs, OutputParams const & runparams) const
}
// Gather a few things from global environment that are shared between all following cases.
FloatList const &floats = buffer().params().documentClass().floats();
Floating const &ftype = floats.getType(params_.type);
FloatList const & floats = buffer().params().documentClass().floats();
Floating const & ftype = floats.getType(params_.type);
// Switch on subfigures.
if (!subfigures.empty())