> > I see the problem now. Will fix soon. It is too late, and unwise to disable label inside listings caption, so the only solution is to process listings parameter afterwards. The attached patch does this. It will be applied to trunk if there is no objection.
Jurgen: OK for branch? Bo
Index: src/insets/InsetListings.cpp =================================================================== --- src/insets/InsetListings.cpp (revision 23850) +++ src/insets/InsetListings.cpp (working copy) @@ -30,6 +30,8 @@ #include "support/docstream.h" #include "support/lstrings.h" +#include <boost/regex.hpp> + #include <sstream> using namespace std; @@ -37,6 +39,7 @@ namespace lyx { +using boost::regex; char const lstinline_delimiters[] = "!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm"; @@ -276,7 +279,23 @@ static_cast<InsetCaption *>(it->inset); ins->getOptArg(ods, runparams); ins->getArgument(ods, runparams); - return ods.str(); + // the caption may contain \label{} but the listings + // package prefer caption={}, label={} + docstring cap = ods.str(); + if (!contains(cap, _("\\label{"))) + return cap; + // convert from + // blah1\label{blah2} blah3 + // to + // blah1 blah3},label={blah2 + // to make listings option + // caption={blah1 blah3},label={blah2} + // + // 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)); } } }