> from what I understand, it looks pretty well done and > works, too.
Thank you for testing. A polished patch has been submitted to trunk, and a patch for branch is attached. Jurgen? Bo
Index: src/insets/InsetListings.cpp =================================================================== --- src/insets/InsetListings.cpp (revision 23853) +++ src/insets/InsetListings.cpp (working copy) @@ -23,6 +23,8 @@ #include "Cursor.h" #include "support/lstrings.h" +#include <boost/regex.hpp> + #include <sstream> namespace lyx { @@ -37,6 +39,8 @@ using std::ostringstream; using std::string; +using boost::regex; + char const lstinline_delimiters[] = "!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm"; void InsetListings::init() @@ -319,7 +323,22 @@ static_cast<InsetCaption *>(it->inset); ins->getOptArg(buf, ods, runparams); ins->getArgument(buf, ods, runparams); - return ods.str(); + // the caption may contain \label{} but the listings + // package prefer caption={}, label={} + docstring cap = ods.str(); + if (!contains(to_utf8(cap), "\\label{")) + return cap; + // convert from + // blah1\label{blah2} blah3 + // to + // blah1 blah3},label={blah2 + // to form options + // 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)); } } } Index: status.15x =================================================================== --- status.15x (revision 23853) +++ status.15x (working copy) @@ -88,6 +88,8 @@ - Fix loading of lyx documents generated with csv2lyx (bug 4639). +- Move \label{} outside of listings option caption={} because the listings + package prefer a separate label={} option. * USER INTERFACE: