mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Implement ParamInfo::HANDLING_LTRIM and use it to ltrim InsetBibitem
output See #9847.
This commit is contained in:
parent
6503073070
commit
76f49fad78
@ -112,7 +112,8 @@ ParamInfo const & InsetBibitem::findInfo(string const & /* cmdName */)
|
|||||||
param_info_.add("label", ParamInfo::LATEX_OPTIONAL,
|
param_info_.add("label", ParamInfo::LATEX_OPTIONAL,
|
||||||
ParamInfo::HANDLING_LATEXIFY);
|
ParamInfo::HANDLING_LATEXIFY);
|
||||||
param_info_.add("key", ParamInfo::LATEX_REQUIRED,
|
param_info_.add("key", ParamInfo::LATEX_REQUIRED,
|
||||||
ParamInfo::HANDLING_ESCAPE);
|
ParamInfo::ParamHandling(ParamInfo::HANDLING_ESCAPE
|
||||||
|
| ParamInfo::HANDLING_LTRIM));
|
||||||
param_info_.add("literal", ParamInfo::LYX_INTERNAL);
|
param_info_.add("literal", ParamInfo::LYX_INTERNAL);
|
||||||
}
|
}
|
||||||
return param_info_;
|
return param_info_;
|
||||||
|
@ -432,12 +432,21 @@ docstring InsetCommandParams::prepareCommand(OutputParams const & runparams,
|
|||||||
docstring const & command,
|
docstring const & command,
|
||||||
ParamInfo::ParamHandling handling) const
|
ParamInfo::ParamHandling handling) const
|
||||||
{
|
{
|
||||||
if (handling == ParamInfo::HANDLING_LATEXIFY)
|
docstring result;
|
||||||
|
bool ltrimmed = false;
|
||||||
|
// Trimming can be done on top of any of the other handlings
|
||||||
|
// We check this here since handling might be changed below.
|
||||||
|
if (handling & ParamInfo::HANDLING_LTRIM) {
|
||||||
|
// this is used if no other handling is done
|
||||||
|
result = command;
|
||||||
|
ltrimmed = true;
|
||||||
|
}
|
||||||
|
if (handling & ParamInfo::HANDLING_LATEXIFY)
|
||||||
if ((*this)["literal"] == "true")
|
if ((*this)["literal"] == "true")
|
||||||
handling = ParamInfo::HANDLING_NONE;
|
handling = ParamInfo::HANDLING_NONE;
|
||||||
docstring result;
|
|
||||||
switch (handling) {
|
// LATEXIFY, ESCAPE and NONE are mutually exclusive
|
||||||
case ParamInfo::HANDLING_LATEXIFY: {
|
if (handling & ParamInfo::HANDLING_LATEXIFY) {
|
||||||
// First handle backslash
|
// First handle backslash
|
||||||
result = subst(command, from_ascii("\\"), from_ascii("\\textbackslash{}"));
|
result = subst(command, from_ascii("\\"), from_ascii("\\textbackslash{}"));
|
||||||
// Then get LaTeX macros
|
// Then get LaTeX macros
|
||||||
@ -476,17 +485,13 @@ docstring InsetCommandParams::prepareCommand(OutputParams const & runparams,
|
|||||||
result.replace(pos, 1, backslash + chars_escape[k] + term);
|
result.replace(pos, 1, backslash + chars_escape[k] + term);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case ParamInfo::HANDLING_ESCAPE:
|
else if (handling & ParamInfo::HANDLING_ESCAPE)
|
||||||
result = escape(command);
|
result = escape(command);
|
||||||
break;
|
else if (handling & ParamInfo::HANDLING_NONE)
|
||||||
case ParamInfo::HANDLING_NONE:
|
|
||||||
result = command;
|
result = command;
|
||||||
break;
|
|
||||||
} // switch
|
|
||||||
|
|
||||||
return result;
|
return ltrimmed ? ltrim(result) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,9 +42,10 @@ public:
|
|||||||
};
|
};
|
||||||
/// Special handling on output
|
/// Special handling on output
|
||||||
enum ParamHandling {
|
enum ParamHandling {
|
||||||
HANDLING_NONE, /// no special handling
|
HANDLING_NONE = 1, /// no special handling
|
||||||
HANDLING_ESCAPE, /// escape special characters
|
HANDLING_ESCAPE = 2, /// escape special characters
|
||||||
HANDLING_LATEXIFY /// transform special characters to LaTeX macros
|
HANDLING_LATEXIFY = 4, /// transform special characters to LaTeX macros
|
||||||
|
HANDLING_LTRIM = 8 /// trim blanks on the left
|
||||||
};
|
};
|
||||||
///
|
///
|
||||||
class ParamData {
|
class ParamData {
|
||||||
|
Loading…
Reference in New Issue
Block a user