mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-22 16:04:07 +00:00
Properly escape splitindex shortcut and try to encode splitindex name properly (part of bug #8227)
This commit is contained in:
parent
51d591d168
commit
5eb9ece39e
@ -1744,10 +1744,20 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
IndicesList::const_iterator iit = indiceslist().begin();
|
||||
IndicesList::const_iterator iend = indiceslist().end();
|
||||
for (; iit != iend; ++iit) {
|
||||
pair<docstring, docstring> indexname_latex =
|
||||
features.runparams().encoding->latexString(iit->index(), features.runparams().dryrun);
|
||||
if (!indexname_latex.second.empty()) {
|
||||
// issue a warning about omitted characters
|
||||
// FIXME: should be passed to the error dialog
|
||||
frontend::Alert::warning(_("Uncodable characters"),
|
||||
bformat(_("The following characters that are used in an index name are not\n"
|
||||
"representable in the current encoding and therefore have been omitted:\n%1$s."),
|
||||
indexname_latex.second));
|
||||
}
|
||||
lyxpreamble += "\\newindex[";
|
||||
lyxpreamble += iit->index();
|
||||
lyxpreamble += indexname_latex.first;
|
||||
lyxpreamble += "]{";
|
||||
lyxpreamble += iit->shortcut();
|
||||
lyxpreamble += escape(iit->shortcut());
|
||||
lyxpreamble += "}\n";
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
if (buffer().masterBuffer()->params().use_indices && !params_.index.empty()
|
||||
&& params_.index != "idx") {
|
||||
os << "\\sindex[";
|
||||
os << params_.index;
|
||||
os << escape(params_.index);
|
||||
os << "]{";
|
||||
} else {
|
||||
os << "\\index";
|
||||
@ -134,15 +134,11 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
// the sorting part are representable in the current
|
||||
// encoding. If not try the LaTeX macro which might
|
||||
// or might not be a good choice, and issue a warning.
|
||||
docstring spart2;
|
||||
for (size_t n = 0; n < spart.size(); ++n) {
|
||||
try {
|
||||
spart2 += runparams.encoding->latexChar(spart[n]).first;
|
||||
} catch (EncodingException & /* e */) {
|
||||
pair<docstring, docstring> spart_latexed =
|
||||
runparams.encoding->latexString(spart, runparams.dryrun);
|
||||
if (!spart_latexed.second.empty())
|
||||
LYXERR0("Uncodable character in index entry. Sorting might be wrong!");
|
||||
}
|
||||
}
|
||||
if (spart != spart2 && !runparams.dryrun) {
|
||||
if (spart != spart_latexed.first && !runparams.dryrun) {
|
||||
// FIXME: warning should be passed to the error dialog
|
||||
frontend::Alert::warning(_("Index sorting failed"),
|
||||
bformat(_("LyX's automatic index sorting algorithm faced\n"
|
||||
@ -152,7 +148,7 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
}
|
||||
// remove remaining \'s for the sorting part
|
||||
docstring const ppart =
|
||||
subst(spart2, from_ascii("\\"), docstring());
|
||||
subst(spart_latexed.first, from_ascii("\\"), docstring());
|
||||
os << ppart;
|
||||
os << '@';
|
||||
}
|
||||
@ -429,7 +425,8 @@ ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
|
||||
{
|
||||
static ParamInfo param_info_;
|
||||
if (param_info_.empty()) {
|
||||
param_info_.add("type", ParamInfo::LATEX_OPTIONAL);
|
||||
param_info_.add("type", ParamInfo::LATEX_OPTIONAL,
|
||||
ParamInfo::HANDLING_ESCAPE);
|
||||
param_info_.add("name", ParamInfo::LATEX_REQUIRED);
|
||||
}
|
||||
return param_info_;
|
||||
|
Loading…
Reference in New Issue
Block a user