[LyX/master] DocBook: fix compilation issues.

Thibaut Cuvelier tcuvelier at lyx.org
Sat Sep 19 18:18:55 UTC 2020


commit faaf780bed0e48eff34390c7c0bdb98e0f41b244
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Tue Aug 25 02:41:07 2020 +0200

    DocBook: fix compilation issues.
---
 src/output_docbook.cpp |   40 +++++++++++++++++++---------------------
 1 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 4e6c30e..ce3f699 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -30,8 +30,6 @@
 
 #include "support/lassert.h"
 
-#include "support/regex.h"
-
 #include <stack>
 #include <iostream>
 #include <algorithm>
@@ -166,18 +164,6 @@ string fontToAttribute(xml::FontTypes type) {
 }
 
 
-xml::FontTag docbookStartFontTag(xml::FontTypes type)
-{
-	return xml::FontTag(from_utf8(fontToDocBookTag(type)), from_utf8(fontToAttribute(type)), type);
-}
-
-
-xml::EndFontTag docbookEndFontTag(xml::FontTypes type)
-{
-	return xml::EndFontTag(from_utf8(fontToDocBookTag(type)), type);
-}
-
-
 // Convenience functions to open and close tags. First, very low-level ones to ensure a consistent new-line behaviour.
 // Block style:
 //	  Content before
@@ -501,13 +487,13 @@ void makeParagraph(
 
 	// Determine if this paragraph has some real content. Things like new pages are not caught
 	// by Paragraph::empty(), even though they do not generate anything useful in DocBook.
+	// Thus, remove all spaces (including new lines: \r, \n) before checking for emptiness.
 	odocstringstream os2;
 	XMLStream xs2(os2);
 	par->simpleDocBookOnePar(buf, xs2, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0);
 
 	docstring cleaned = os2.str();
-	static const lyx::regex reg("[ \\r\\n]*");
-	cleaned = from_utf8(lyx::regex_replace(to_utf8(cleaned), reg, string("")));
+	cleaned.erase(std::remove_if(cleaned.begin(), cleaned.end(), ::isspace), cleaned.end());
 
 	if (!cleaned.empty()) {
 		if (open_par)
@@ -658,8 +644,6 @@ void makeAny(
 	}
 }
 
-} // end anonymous namespace
-
 
 using DocBookDocumentSectioning = tuple<bool, pit_type>;
 
@@ -796,6 +780,20 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const &paragraphs, pit_type b
 	return DocBookInfoTag(shouldBeInInfo, mustBeInInfo, abstract, bpit, cpit);
 }
 
+} // end anonymous namespace
+
+
+xml::FontTag docbookStartFontTag(xml::FontTypes type)
+{
+	return xml::FontTag(from_utf8(fontToDocBookTag(type)), from_utf8(fontToAttribute(type)), type);
+}
+
+
+xml::EndFontTag docbookEndFontTag(xml::FontTypes type)
+{
+	return xml::EndFontTag(from_utf8(fontToDocBookTag(type)), type);
+}
+
 
 void outputDocBookInfo(
 		Text const & text,
@@ -829,11 +827,11 @@ 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.
 		abstract = os2.str();
-		static const lyx::regex reg("[ \\r\\n]*");
-		docstring abstractContent = from_utf8(lyx::regex_replace(to_utf8(abstract), reg, string("")));
+		docstring cleaned = abstract;
+		cleaned.erase(std::remove_if(cleaned.begin(), cleaned.end(), ::isspace), cleaned.end());
 
 		// Nothing? Then there is no abstract!
-		if (abstractContent.empty())
+		if (cleaned.empty())
 			hasAbstract = false;
 	}
 


More information about the lyx-cvs mailing list