]> git.lyx.org Git - features.git/commitdiff
Fix bug #10705
authorEnrico Forestieri <forenr@lyx.org>
Mon, 26 Jun 2017 21:10:30 +0000 (23:10 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Mon, 26 Jun 2017 21:10:30 +0000 (23:10 +0200)
Seemingly, std::regex does not account for newlines in the string.

src/insets/InsetListings.cpp
status.22x

index 207e98bacdc4a4ea92c1337697c3776dcd21c093..66dca57fdd101b1abab16835d10965ad95c88900 100644 (file)
@@ -420,7 +420,11 @@ docstring InsetListings::getCaption(OutputParams const & runparams) const
        // NOTE that } is not allowed in blah2.
        regex const reg("(.*)\\\\label\\{(.*?)\\}(.*)");
        string const new_cap("$1$3},label={$2");
-       return from_utf8(regex_replace(to_utf8(cap), reg, new_cap));
+       // Replace '\n' with an improbable character from Private Use Area-A
+       // and then return to '\n' after the regex replacement.
+       string const capstr = to_utf8(subst(cap, char_type('\n'), 0xffffd));
+       return subst(from_utf8(regex_replace(capstr, reg, new_cap)),
+                    0xffffd, char_type('\n'));
 }
 
 
index c48eb529a7ec903b9e99876509c0994f95d9fd8a..d516bfb334a59e084e2f6632a53d7422b90adcd4 100644 (file)
@@ -49,6 +49,9 @@ What's new
 
 - Catch "! Incomplete \if[x]" LaTeX error (bug 10666).
 
+- Fix caption handling in listings insets when it is split into multiple
+  lines in the LaTeX output (bug 10705).
+
 
 * LYX2LYX