DocBook: don't force outputting an <abstract> when it would only contain comments.

Before this patch, LyX would forcibly create an <abstract> tag even when there was no abstract in the document; this behaviour is sometimes desirable, but not when the abstract only contains comments (that's not valid DocBook: there must be a paragraph or assimilated within the abstract).
This commit is contained in:
Thibaut Cuvelier 2022-02-06 06:44:29 +01:00
parent 34ea4080ec
commit 643cbfe557

View File

@ -1020,12 +1020,20 @@ 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.
// Actually output the abstract if there is something to do. Don't count line feeds, spaces, or comments
// in this -- even though line feeds and spaces must be properly output if there is some abstract.
abstract = os2.str();
docstring cleaned = abstract;
cleaned.erase(std::remove_if(cleaned.begin(), cleaned.end(), lyx::isSpace), cleaned.end());
size_t beginComment;
size_t endComment;
while ((beginComment = cleaned.find(from_ascii("<!--"))) != lyx::docstring::npos) {
if ((endComment = cleaned.find(from_ascii("-->"), beginComment)) != lyx::docstring::npos) {
cleaned.erase(cleaned.begin() + beginComment, cleaned.begin() + endComment + 3);
}
}
// Nothing? Then there is no abstract!
if (cleaned.empty())
hasAbstract = false;