From faaf780bed0e48eff34390c7c0bdb98e0f41b244 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 25 Aug 2020 02:41:07 +0200 Subject: [PATCH] DocBook: fix compilation issues. --- src/output_docbook.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 4e6c30e545..ce3f6991b5 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -30,8 +30,6 @@ #include "support/lassert.h" -#include "support/regex.h" - #include #include #include @@ -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; @@ -796,6 +780,20 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, 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; }