mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
Correctly track opened polyglossia languages
A language switch may also occur outside of output_latex.cpp, apparently.
This commit is contained in:
parent
6a3ced3cfb
commit
8c14d9e041
@ -287,6 +287,7 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
|
|||||||
tmp += "{";
|
tmp += "{";
|
||||||
os << from_ascii(tmp);
|
os << from_ascii(tmp);
|
||||||
count += tmp.length();
|
count += tmp.length();
|
||||||
|
runparams.pushPolyglossiaLang(language()->polyglossia());
|
||||||
} else if (language()->encoding()->package() != Encoding::CJK) {
|
} else if (language()->encoding()->package() != Encoding::CJK) {
|
||||||
os << '{';
|
os << '{';
|
||||||
count += 1;
|
count += 1;
|
||||||
@ -545,6 +546,8 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
|
|||||||
&& language()->encoding()->package() != Encoding::CJK) {
|
&& language()->encoding()->package() != Encoding::CJK) {
|
||||||
os << '}';
|
os << '}';
|
||||||
++count;
|
++count;
|
||||||
|
if (runparams.use_polyglossia)
|
||||||
|
runparams.popPolyglossiaLang();
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
@ -21,7 +21,8 @@ namespace lyx {
|
|||||||
OutputParams::OutputParams(Encoding const * enc)
|
OutputParams::OutputParams(Encoding const * enc)
|
||||||
: flavor(LATEX), math_flavor(NotApplicable), nice(false), is_child(false),
|
: flavor(LATEX), math_flavor(NotApplicable), nice(false), is_child(false),
|
||||||
moving_arg(false), intitle(false), inulemcmd(0), local_font(0), master_language(0),
|
moving_arg(false), intitle(false), inulemcmd(0), local_font(0), master_language(0),
|
||||||
encoding(enc), free_spacing(false), use_babel(false), use_polyglossia(false),
|
encoding(enc), pushPolyglossiaLang(0), popPolyglossiaLang(0),
|
||||||
|
free_spacing(false), use_babel(false), use_polyglossia(false),
|
||||||
use_indices(false), use_japanese(false), linelen(0), depth(0),
|
use_indices(false), use_japanese(false), linelen(0), depth(0),
|
||||||
exportdata(new ExportData),
|
exportdata(new ExportData),
|
||||||
inComment(false), inTableCell(NO), inFloat(NONFLOAT),
|
inComment(false), inTableCell(NO), inFloat(NONFLOAT),
|
||||||
|
@ -141,6 +141,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
mutable Encoding const * encoding;
|
mutable Encoding const * encoding;
|
||||||
|
|
||||||
|
/** Pointer to a function for registering a language switch
|
||||||
|
when using polyglossia.
|
||||||
|
*/
|
||||||
|
mutable void (* pushPolyglossiaLang)(std::string const & lang_name);
|
||||||
|
|
||||||
|
/** Pointer to a function for unregistering the last language
|
||||||
|
switch when using polyglossia.
|
||||||
|
*/
|
||||||
|
mutable void (* popPolyglossiaLang)();
|
||||||
|
|
||||||
/** free_spacing == true means that the inset is in a free-spacing
|
/** free_spacing == true means that the inset is in a free-spacing
|
||||||
paragraph.
|
paragraph.
|
||||||
*/
|
*/
|
||||||
|
@ -2441,6 +2441,8 @@ void Paragraph::latex(BufferParams const & bparams,
|
|||||||
running_lang);
|
running_lang);
|
||||||
os << from_ascii(end_tag);
|
os << from_ascii(end_tag);
|
||||||
column += end_tag.length();
|
column += end_tag.length();
|
||||||
|
if (runparams.use_polyglossia)
|
||||||
|
runparams.popPolyglossiaLang();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch file encoding if necessary (and allowed)
|
// Switch file encoding if necessary (and allowed)
|
||||||
|
@ -478,6 +478,24 @@ void getArgInsets(otexstream & os, OutputParams const & runparams, Layout::LaTeX
|
|||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
|
void pushPolyglossiaLang(string const & lang_name)
|
||||||
|
{
|
||||||
|
OutputState * state = getOutputState();
|
||||||
|
|
||||||
|
state->lang_switch_depth_.push(state->nest_level_);
|
||||||
|
state->open_polyglossia_lang_.push(lang_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void popPolyglossiaLang()
|
||||||
|
{
|
||||||
|
OutputState * state = getOutputState();
|
||||||
|
|
||||||
|
state->lang_switch_depth_.pop();
|
||||||
|
state->open_polyglossia_lang_.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void latexArgInsets(Paragraph const & par, otexstream & os,
|
void latexArgInsets(Paragraph const & par, otexstream & os,
|
||||||
OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs, string const & prefix)
|
OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs, string const & prefix)
|
||||||
{
|
{
|
||||||
@ -1265,8 +1283,15 @@ void latexParagraphs(Buffer const & buf,
|
|||||||
: subst(lang_begin_command, "$$lang", mainlang);
|
: subst(lang_begin_command, "$$lang", mainlang);
|
||||||
os << bc;
|
os << bc;
|
||||||
os << '\n';
|
os << '\n';
|
||||||
|
if (runparams.use_polyglossia) {
|
||||||
|
state->lang_switch_depth_.push(state->nest_level_);
|
||||||
|
state->open_polyglossia_lang_.push(mainlang);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runparams.pushPolyglossiaLang = pushPolyglossiaLang;
|
||||||
|
runparams.popPolyglossiaLang = popPolyglossiaLang;
|
||||||
|
|
||||||
ParagraphList const & paragraphs = text.paragraphs();
|
ParagraphList const & paragraphs = text.paragraphs();
|
||||||
|
|
||||||
if (runparams.par_begin == runparams.par_end) {
|
if (runparams.par_begin == runparams.par_end) {
|
||||||
|
@ -29,6 +29,14 @@ class Paragraph;
|
|||||||
class OutputParams;
|
class OutputParams;
|
||||||
class Text;
|
class Text;
|
||||||
|
|
||||||
|
/** Register a language switch when using polyglossia.
|
||||||
|
*/
|
||||||
|
void pushPolyglossiaLang(std::string const & lang);
|
||||||
|
|
||||||
|
/** Unregister the last language switch when using polyglossia.
|
||||||
|
*/
|
||||||
|
void popPolyglossiaLang();
|
||||||
|
|
||||||
/** Export optional and required arguments of the paragraph \p par.
|
/** Export optional and required arguments of the paragraph \p par.
|
||||||
Non-existing required arguments are output empty: {}.
|
Non-existing required arguments are output empty: {}.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user