]> git.lyx.org Git - features.git/commitdiff
Fix bug #11484
authorEnrico Forestieri <forenr@lyx.org>
Mon, 4 Feb 2019 09:49:02 +0000 (10:49 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 12:39:57 +0000 (14:39 +0200)
When splitting parameters at commas, take into account that
commas inside curly braces are not parameter separators.

src/insets/InsetInclude.cpp

index 8d1a4a87c5896cc7e7b0aacc0f8e42ce39a45703..121b1ad8a9a93e8fa866d225206f166d354e342f 100644 (file)
@@ -165,6 +165,23 @@ InsetLabel * createLabel(Buffer * buf, docstring const & label_str)
        return new InsetLabel(buf, icp);
 }
 
+
+char_type replaceCommaInBraces(docstring & params)
+{
+       // Code point from private use area
+       char_type private_char = 0xE000;
+       int count = 0;
+       for (char_type & c : params) {
+               if (c == '{')
+                       ++count;
+               else if (c == '}')
+                       --count;
+               else if (c == ',' && count)
+                       c = private_char;
+       }
+       return private_char;
+}
+
 } // namespace
 
 
@@ -625,12 +642,18 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                docstring label;
                docstring placement;
                bool isfloat = lstparams.isFloat();
+               // We are going to split parameters at commas, so
+               // replace commas that are not parameter separators
+               // with a code point from the private use area
+               char_type comma = replaceCommaInBraces(parameters);
                // Get float placement, language, caption, and
                // label, then remove the relative options if minted.
                vector<docstring> opts =
                        getVectorFromString(parameters, from_ascii(","), false);
                vector<docstring> latexed_opts;
                for (size_t i = 0; i < opts.size(); ++i) {
+                       // Restore replaced commas
+                       opts[i] = subst(opts[i], comma, ',');
                        if (use_minted && prefixIs(opts[i], from_ascii("float"))) {
                                if (prefixIs(opts[i], from_ascii("float=")))
                                        placement = opts[i].substr(6);