On Mon, Oct 17, 2016 at 00:16:21AM +0200, Guillaume Munch wrote:

> commit 676a0639c505d52336e3228c44c2515ccbbaf34a
> Author: Guillaume Munch <g...@lyx.org>
> Date:   Sat Sep 24 00:49:00 2016 +0200
> 
>     Use otexstringstream for the captions of InsetCaptionables
>     
>     * Enable TexRow for InsetListings caption.
>     
>     * Move getCaption* from InsetText to InsetCaptionable.
>     
>     * Clean-up caption generation for InsetFloat.
[...]
> @@ -420,7 +417,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));
> +     // 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));
> +     return cap;
>  }
>  
>  

This commit broke the caption handling in InsetListings. For example,
the document attached at #9382:
https://www.lyx.org/trac/raw-attachment/ticket/9382/problem.20_nopreamble.lyx
now fails to compile. It can be compiled again with the attached patch,
which is not the right one, of course.

-- 
Enrico
diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp
index b847131f57..43b5a65342 100644
--- a/src/insets/InsetListings.cpp
+++ b/src/insets/InsetListings.cpp
@@ -515,7 +515,8 @@ 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));
+       string const capstr = subst(to_utf8(cap.str), '\n', '@');
+       cap.str = from_utf8(subst(regex_replace(capstr, reg, new_cap), '@', 
'\n'));
        return cap;
 }
 

Reply via email to