Add proper support for BabelProvide 2

We need to instruct babel not to load an existing ldf in this case
This commit is contained in:
Juergen Spitzmueller 2024-08-25 14:56:05 +02:00
parent 8aaaa53c5b
commit fc605cf138
3 changed files with 28 additions and 3 deletions

View File

@ -891,6 +891,7 @@ Language hebrew
GuiName "Hebrew" GuiName "Hebrew"
HasGuiSupport true HasGuiSupport true
BabelName hebrew BabelName hebrew
BabelProvide 2
PolyglossiaName hebrew PolyglossiaName hebrew
XindyName hebrew XindyName hebrew
Encoding cp1255 Encoding cp1255

View File

@ -1010,6 +1010,11 @@ def revert_new_babel_languages(document):
if have_oldrussian: if have_oldrussian:
add_to_preamble(document, ["\\AddToHook{package/babel/after}{\\languageattribute{russian}{ancient}}"]) add_to_preamble(document, ["\\AddToHook{package/babel/after}{\\languageattribute{russian}{ancient}}"])
# Some babel languages require special treatment with unicode engines
if get_bool_value(document.header, "\\use_non_tex_fonts"):
if document.language == "hebrew" or find_token(document.body, "\\lang oldrussian", 0) != -1:
add_to_preamble(document, ["\\PassOptionsToPackage{provide*=*}{babel}"])
## ##
# Conversion hub # Conversion hub
# #

View File

@ -3504,6 +3504,7 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
// add main language // add main language
langs.insert(language); langs.insert(language);
ostringstream os; ostringstream os;
string force_provide;
for (auto const & l : langs) { for (auto const & l : langs) {
string blang = l->babel(); string blang = l->babel();
bool use_opt = langoptions; bool use_opt = langoptions;
@ -3523,7 +3524,8 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
use_opt = true; use_opt = true;
} }
} }
if (l->useBabelProvide() == 1 || (l->useBabelProvide() == 2 && useNonTeXFonts)) { int const bp = l->useBabelProvide();
if (bp == 1) {
os << "\n\\babelprovide[import"; os << "\n\\babelprovide[import";
if (l == language) if (l == language)
os << ", main"; os << ", main";
@ -3532,11 +3534,28 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
os << "]{" << blang << "}"; os << "]{" << blang << "}";
have_mods = true; have_mods = true;
} }
else if (use_opt) if (bp == 2 && useNonTeXFonts) {
// here we need to tell babel to use the ini
// even though an *.ldf exists
if (l == language)
force_provide = force_provide.empty()
? "provide=*"
: "provide*=*";
else
force_provide = "provide+=*";
have_mods = true;
}
if (bp != 1 && use_opt)
blangs.push_back(blang); blangs.push_back(blang);
} }
if (have_mods) if (have_mods) {
lang_opts = getStringFromVector(blangs); lang_opts = getStringFromVector(blangs);
if (!force_provide.empty()) {
if (!lang_opts.empty())
lang_opts += ", ";
lang_opts += force_provide;
}
}
// The prefs may require the languages to // The prefs may require the languages to
// be submitted to babel itself (not the class). // be submitted to babel itself (not the class).
if ((langoptions || have_mods) && !lang_opts.empty()) if ((langoptions || have_mods) && !lang_opts.empty())