Fix cprotect with Slovak

babel-slovak makes ^ active, though cprotect relies on it being
catcode 9 ("ignored"). Thus we locally change the catcode with Slovak.
This commit is contained in:
Juergen Spitzmueller 2019-08-14 14:00:29 +02:00
parent ce447e1760
commit f995fba310
4 changed files with 40 additions and 8 deletions

View File

@ -1336,7 +1336,7 @@ Language slovak
BabelName slovak
PolyglossiaName slovak
QuoteStyle german
ActiveChars -
ActiveChars -^
Encoding iso8859-2
FontEncoding T1|OT1
DateFormats "d. MMMM yyyy|d. MMM yyyy|d.M.yyyy"

View File

@ -396,6 +396,7 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
if (stdwidth && !(buffer().params().paragraph_separation))
os << "\\noindent";
bool needendgroup = false;
switch (btype) {
case Frameless:
break;
@ -439,8 +440,14 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
} else {
if (params_.framecolor != "black" || params_.backgroundcolor != "none")
os << "\\fcolorbox{" << params_.framecolor << "}{" << params_.backgroundcolor << "}";
else
else {
if (!cprotect.empty() && contains(runparams.active_chars, '^')) {
// cprotect relies on ^ being ignored
os << "\\begingroup\\catcode`\\^=9";
needendgroup = true;
}
os << cprotect << "\\fbox";
}
}
os << "{";
break;
@ -590,8 +597,10 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
if (!params_.inner_box && !width_string.empty()
&& (params_.framecolor != "black" || params_.backgroundcolor != "none"))
os << "}";
if (separation_string != defaultSep || thickness_string != defaultThick)
if (separation_string != defaultSep || thickness_string != defaultThick)
os << "}";
if (needendgroup)
os << "\\endgroup";
break;
case ovalbox:
os << "}";

View File

@ -454,14 +454,20 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
InsetLayout const & il = getLayout();
if (il.forceOwnlines())
os << breakln;
bool needendgroup = false;
if (!il.latexname().empty()) {
if (il.latextype() == InsetLayout::COMMAND) {
// FIXME UNICODE
// FIXME \protect should only be used for fragile
// commands, but we do not provide this information yet.
if (hasCProtectContent(runparams.moving_arg))
if (hasCProtectContent(runparams.moving_arg)) {
if (contains(runparams.active_chars, '^')) {
// cprotect relies on ^ being ignored
os << "\\begingroup\\catcode`\\^=9";
needendgroup = true;
}
os << "\\cprotect";
else if (runparams.moving_arg)
} else if (runparams.moving_arg)
os << "\\protect";
os << '\\' << from_utf8(il.latexname());
if (!il.latexargs().empty())
@ -522,6 +528,8 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
os << "}";
if (!il.postcommandargs().empty())
getArgs(os, runparams, true);
if (needendgroup)
os << "\\endgroup";
} else if (il.latextype() == InsetLayout::ENVIRONMENT) {
// A comment environment doesn't need a % before \n\end
if (il.isDisplay() || runparams.inComment)

View File

@ -679,8 +679,12 @@ void parStartCommand(Paragraph const & par, otexstream & os,
{
switch (style.latextype) {
case LATEX_COMMAND:
if (par.needsCProtection(runparams.moving_arg))
if (par.needsCProtection(runparams.moving_arg)) {
if (contains(runparams.active_chars, '^'))
// cprotect relies on ^ being ignored
os << "\\begingroup\\catcode`\\^=9";
os << "\\cprotect";
}
os << '\\' << from_ascii(style.latexname());
// Command arguments
@ -794,8 +798,13 @@ void TeXOnePar(Buffer const & buf,
// I did not create a parEndCommand for this minuscule
// task because in the other user of parStartCommand
// the code is different (JMarc)
if (style.isCommand())
os << "}\n";
if (style.isCommand()) {
os << "}";
if (par.needsCProtection(runparams.moving_arg)
&& contains(runparams.active_chars, '^'))
os << "\\endgroup";
os << "\n";
}
else
os << '\n';
if (!style.parbreak_is_newline) {
@ -1116,6 +1125,9 @@ void TeXOnePar(Buffer const & buf,
os << runparams.post_macro;
runparams.post_macro.clear();
}
if (par.needsCProtection(runparams.moving_arg)
&& contains(runparams.active_chars, '^'))
os << "\\endgroup";
if (runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding;
os << setEncoding(prev_encoding->iconvName());
@ -1280,6 +1292,9 @@ void TeXOnePar(Buffer const & buf,
os << runparams.post_macro;
runparams.post_macro.clear();
}
if (par.needsCProtection(runparams.moving_arg)
&& contains(runparams.active_chars, '^'))
os << "\\endgroup";
if (runparams.encoding != prev_encoding) {
runparams.encoding = prev_encoding;
os << setEncoding(prev_encoding->iconvName());