From 841f0fd3dd717ffed0d159b755eaacabab7f41a0 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Mon, 4 Feb 2019 10:49:02 +0100 Subject: [PATCH] Fix bug #11484 When splitting parameters at commas, take into account that commas inside curly braces are not parameter separators. (cherry picked from commit 6316b9b7aed7d67c585f8c17cce5669f8cbb5d65) --- src/insets/InsetInclude.cpp | 23 +++++++++++++++++++++++ status.23x | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 437e0ea309..7c0d6ce550 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -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 @@ -617,12 +634,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 opts = getVectorFromString(parameters, from_ascii(","), false); vector 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); diff --git a/status.23x b/status.23x index 2d7bd62fa4..e1402cfa1a 100644 --- a/status.23x +++ b/status.23x @@ -87,6 +87,8 @@ What's new - Fix LaTeX export of query strings in Hyperlinks (bug 11482). +- Fix breakage caused by commas in the caption of listings (bug 11484). + * USER INTERFACE -- 2.39.5