lang_end_command = "}";
lang_command_termination.clear();
}
-
+
bool const localswitch_needed = localswitch && par_lang != outer_lang;
// localswitches need to be closed and reopened at each par
if (!localswitch
&& (!using_begin_end || langOpenedAtThisLevel(state))
&& !lang_end_command.empty()
- && prev_lang != outer_lang
+ && prev_lang != outer_lang
&& !prev_lang.empty()
&& (!using_begin_end || !style.isEnvironment())) {
os << from_ascii(subst(lang_end_command,
}
// If this is the last paragraph, close the CJK environment
- // if necessary. If it's an environment, we'll have to \end that first.
- if (runparams.isLastPar && !style.isEnvironment()) {
+ // if necessary. If it's an environment or nested in an environment,
+ // we'll have to \end that first.
+ if (runparams.isLastPar && !style.isEnvironment()
+ && par.params().depth() < 1) {
switch (state->open_encoding_) {
case CJK: {
// do nothing at the end of child documents
// If the last paragraph is an environment, we'll have to close
// CJK at the very end to do proper nesting.
if (maintext && !is_child && state->open_encoding_ == CJK) {
- os << "\\end{CJK}\n";
+ os << "\\clearpage\n\\end{CJK}\n";
state->open_encoding_ = none;
}
// Likewise for polyglossia or when using begin/end commands
// except if we use CJKutf8
bool const from_to_cjk =
((oldEnc.package() == Encoding::CJK && newEnc.package() != Encoding::CJK)
- || (oldEnc.package() != Encoding::CJK && newEnc.package() == Encoding::CJK))
- && (bparams.encoding().name() != "utf8-cjk" || !LaTeXFeatures::isAvailable("CJKutf8"));
+ || (oldEnc.package() != Encoding::CJK && newEnc.package() == Encoding::CJK))
+ && ((bparams.encoding().name() != "utf8-cjk" && bparams.encoding().name() != "utf8")
+ || !LaTeXFeatures::isAvailable("CJKutf8"));
if (!force && !from_to_cjk
&& ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg))
return make_pair(false, 0);
// This does of course only work in special cases (e.g. switch from
// tis620-0 to latin1, but the text in latin1 contains ASCII only),
// but it is the best we can do
- //
+ //
// 2019-01-08 Possibly no longer required since tis620-0 is supported
// by inputenc (but check special encodings "utf8-plain" and "default").
if (oldEnc.package() == Encoding::none || newEnc.package() == Encoding::none)
return make_pair(false, 0);
- LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
- << oldEnc.name() << " to " << newEnc.name());
- os << setEncoding(newEnc.iconvName());
- if (bparams.inputenc == "default")
- return make_pair(true, 0);
+ // change encoding (not required with UTF8)
+ if (bparams.encoding().iconvName() != "UTF-8") {
+ LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
+ << oldEnc.name() << " to " << newEnc.name());
+ os << setEncoding(newEnc.iconvName());
+ if (bparams.inputenc == "default")
+ return make_pair(true, 0);
+ }
docstring const inputenc_arg(from_ascii(newEnc.latexName()));
OutputState * state = getOutputState();
}
// Dead code to avoid a warning:
return make_pair(true, 0);
-
}
} // namespace lyx