mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Fix backslash LaTeXifying in InsetCommand
\ was transformed very early to \textbackslash{}, but then the following routines escaped braces in the string, so we wrongly ended up in \textbackslash\{\} and "\{} in the output
This commit is contained in:
parent
812e306dad
commit
a020bbc4a8
@ -455,7 +455,21 @@ docstring InsetCommandParams::prepareCommand(OutputParams const & runparams,
|
||||
// LATEXIFY, ESCAPE and NONE are mutually exclusive
|
||||
if (handling & ParamInfo::HANDLING_LATEXIFY) {
|
||||
// First handle backslash
|
||||
result = subst(command, from_ascii("\\"), from_ascii("\\textbackslash{}"));
|
||||
// we cannot replace yet with \textbackslash{}
|
||||
// as the braces would be erroneously escaped
|
||||
// in the following routines ("\textbackslash\{\}").
|
||||
// So create a unique placeholder which is replaced
|
||||
// in the end.
|
||||
docstring bs = from_ascii("@LyXBackslash@");
|
||||
// We are super-careful and assure the placeholder
|
||||
// does not exist in the string
|
||||
for (int i = 0; ; ++i) {
|
||||
if (!contains(command, bs)) {
|
||||
result = subst(command, from_ascii("\\"), bs);
|
||||
break;
|
||||
}
|
||||
bs = from_ascii("@LyXBackslash") + i + '@';
|
||||
}
|
||||
// Then get LaTeX macros
|
||||
pair<docstring, docstring> command_latexed =
|
||||
runparams.encoding->latexString(result, runparams.dryrun);
|
||||
@ -493,6 +507,8 @@ docstring InsetCommandParams::prepareCommand(OutputParams const & runparams,
|
||||
result.replace(pos, 1, backslash + chars_escape[k] + term);
|
||||
}
|
||||
}
|
||||
// set in real backslash now
|
||||
result = subst(result, bs, from_ascii("\\textbackslash{}"));
|
||||
}
|
||||
else if (handling & ParamInfo::HANDLING_ESCAPE)
|
||||
result = escape(command);
|
||||
|
Loading…
Reference in New Issue
Block a user