From d87513a94dd31e22d1b1bc04e9fddcc8ddcc634a Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Mon, 26 Jun 2017 16:14:27 +0200 Subject: [PATCH] Fix bug #10705 Seemingly, std::regex does not account for newlines in the string. --- src/insets/InsetListings.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index b847131f57..cf5892edec 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -515,7 +515,11 @@ TexString InsetListings::getCaption(OutputParams const & runparams) const // TexString validity: the substitution preserves the number of newlines. // Moreover we assume that $2 does not contain newlines, so that the texrow // information remains accurate. - cap.str = from_utf8(regex_replace(to_utf8(cap.str), reg, new_cap)); + // Replace '\n' with an improbable character from Private Use Area-A + // and then return to '\n' after the regex replacement. + docstring const capstr = subst(cap.str, char_type('\n'), 0xffffd); + cap.str = subst(from_utf8(regex_replace(to_utf8(capstr), reg, new_cap)), + 0xffffd, char_type('\n')); return cap; } -- 2.39.5