commit e40fa86a975a5d3ec7ecc0a1d33d082774ba7cb2
Author: Enrico Forestieri <[email protected]>
Date: Tue Sep 27 21:41:13 2016 +0200
Do not unnecessarily open the document language
If the document language is opened outside of any environement, we risk
not closing it if no other language switch occurs. Indeed, the stack is
emptied only at the end of an enviroment. We could of course also empty
it at the end of the document, but we would have an unnecessary language
switch.
---
src/output_latex.cpp | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index 0765949..4e40b6f 100644
--- a/src/output_latex.cpp
+++ b/src/output_latex.cpp
@@ -210,9 +210,17 @@ static TeXEnvironmentData prepareEnvironment(Buffer const
& buf,
}
}
+ // If no language was explicitly opened and we are using
+ // polyglossia, then the current polyglossia language is
+ // the document language.
+ string const & pol_lang = use_polyglossia
+ && state->lang_switch_depth_.size()
+ ? openPolyglossiaLang(state)
+ : doc_lang;
+
if ((lang_end_command.empty() ||
par_lang != doc_lang ||
- par_lang != openPolyglossiaLang(state)) &&
+ par_lang != pol_lang) &&
!par_lang.empty()) {
string bc = use_polyglossia ?
getPolyglossiaBegin(lang_begin_command,
par_lang,