mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Only strip outer braces in listings options
trim stripped also multiple subsequent braces
This commit is contained in:
parent
7b5fe0321e
commit
b29b0f8754
@ -176,6 +176,16 @@ char_type replaceCommaInBraces(docstring & params)
|
|||||||
return private_char;
|
return private_char;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
docstring stripOuterBraces(docstring & str)
|
||||||
|
{
|
||||||
|
// trim only first and last occurrence of { and }
|
||||||
|
if (prefixIs(str, from_ascii("{")))
|
||||||
|
str = str.substr(1, docstring::npos);
|
||||||
|
if (suffixIs(str, from_ascii("}")))
|
||||||
|
str = str.substr(0, str.size() - 1);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
@ -699,13 +709,15 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
language = opts[i].substr(9);
|
language = opts[i].substr(9);
|
||||||
opts.erase(opts.begin() + i--);
|
opts.erase(opts.begin() + i--);
|
||||||
} else if (prefixIs(opts[i], from_ascii("caption="))) {
|
} else if (prefixIs(opts[i], from_ascii("caption="))) {
|
||||||
caption = params().prepareCommand(runparams, trim(opts[i].substr(8), "{}"),
|
caption = opts[i].substr(8);
|
||||||
|
caption = params().prepareCommand(runparams, stripOuterBraces(caption),
|
||||||
ParamInfo::HANDLING_LATEXIFY);
|
ParamInfo::HANDLING_LATEXIFY);
|
||||||
opts.erase(opts.begin() + i--);
|
opts.erase(opts.begin() + i--);
|
||||||
if (!use_minted)
|
if (!use_minted)
|
||||||
latexed_opts.push_back(from_ascii("caption={") + caption + "}");
|
latexed_opts.push_back(from_ascii("caption={") + caption + "}");
|
||||||
} else if (prefixIs(opts[i], from_ascii("label="))) {
|
} else if (prefixIs(opts[i], from_ascii("label="))) {
|
||||||
label = params().prepareCommand(runparams, trim(opts[i].substr(6), "{}"),
|
label = opts[i].substr(6);
|
||||||
|
label = params().prepareCommand(runparams, stripOuterBraces(label),
|
||||||
ParamInfo::HANDLING_ESCAPE);
|
ParamInfo::HANDLING_ESCAPE);
|
||||||
opts.erase(opts.begin() + i--);
|
opts.erase(opts.begin() + i--);
|
||||||
if (!use_minted)
|
if (!use_minted)
|
||||||
@ -713,7 +725,7 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
}
|
}
|
||||||
if (use_minted && !label.empty()) {
|
if (use_minted && !label.empty()) {
|
||||||
if (isfloat || !caption.empty())
|
if (isfloat || !caption.empty())
|
||||||
label = trim(label, "{}");
|
label = stripOuterBraces(label);
|
||||||
else
|
else
|
||||||
opts.push_back(from_ascii("label=") + label);
|
opts.push_back(from_ascii("label=") + label);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user