Seemingly, std::regex does not account for newlines in the string.
This commit is contained in:
Enrico Forestieri 2017-06-26 16:14:27 +02:00
parent 80f3f219b7
commit d87513a94d

View File

@ -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;
}