+std::set<const Inset *> gatherInfo(ParagraphList::const_iterator par)
+{
+ // This function has a structure highly similar to makeAny and its friends. It's only made to be called on what
+ // should become the document's <abstract>.
+ std::set<const Inset *> values;
+
+ // If this kind of layout should be ignored, already leave.
+ if (par->layout().docbooktag() == "IGNORE")
+ return values;
+
+ // If this should go in info, mark it as such. Dive deep into the abstract, as it may hide many things that
+ // DocBook doesn't want to be inside the abstract.
+ for (pos_type i = 0; i < par->size(); ++i) {
+ if (par->getInset(i) && par->getInset(i)->asInsetText()) {
+ InsetText const *inset = par->getInset(i)->asInsetText();
+
+ if (inset->getLayout().docbookininfo() != "never") {
+ values.insert(inset);
+ } else {
+ auto subpar = inset->paragraphs().begin();
+ while (subpar != inset->paragraphs().end()) {
+ auto subinfos = gatherInfo(subpar);
+ for (auto & subinfo: subinfos)
+ values.insert(subinfo);
+ ++subpar;
+ }
+ }
+ }
+ }
+
+ return values;
+}
+
+
+ParagraphList::const_iterator makeAny(Text const &text,
+ Buffer const &buf,
+ XMLStream &xs,
+ OutputParams const &runparams,
+ ParagraphList::const_iterator par)
+{
+ bool ignoreParagraph = false;
+
+ // If this kind of layout should be ignored, already leave.
+ ignoreParagraph |= par->layout().docbooktag() == "IGNORE";
+
+ // For things that should go into <info>, check the variable rp.docbook_generate_info. This does not apply to the
+ // abstract itself.
+ bool isAbstract = par->layout().docbookabstract() || par->layout().docbooktag() == "abstract";
+ ignoreParagraph |= !isAbstract && par->layout().docbookininfo() != "never" && !runparams.docbook_generate_info;
+
+ // Switch on the type of paragraph to call the right handler.
+ if (!ignoreParagraph) {
+ switch (par->layout().latextype) {
+ case LATEX_COMMAND:
+ 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:
+ // 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;
+ case LATEX_BIB_ENVIRONMENT:
+ makeBibliography(text, buf, xs, runparams, par);
+ break;
+ }
+ }
+
+ // For cases that are not lists, the next paragraph to handle is the next one.
+ ++par;
+ return par;
+}
+
+