commit 643cbfe557a61cef62a9c4c19c80029735f8bd4b
Author: Thibaut Cuvelier <[email protected]>
Date:   Sun Feb 6 06:44:29 2022 +0100

    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).
---
 src/output_docbook.cpp |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 71d3b83..5458e7a 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -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;
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to