Handle optval when translating names.

This commit is contained in:
Tom Alexander 2023-10-11 18:50:22 -04:00
parent b1a0fa4acf
commit 51429e3155
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -103,12 +103,16 @@ pub(crate) fn parse_affiliated_keywords<'g, 's>(
}
fn translate_name<'g, 's>(global_settings: &'g GlobalSettings<'g, 's>, name: &'s str) -> String {
let name_until_optval = name
.split_once("[")
.map(|(before, _after)| before)
.unwrap_or(name);
for (src, dst) in global_settings.element_keyword_translation_alist {
if name.eq_ignore_ascii_case(src) {
if name_until_optval.eq_ignore_ascii_case(src) {
return dst.to_lowercase();
}
}
name.to_lowercase()
name_until_optval.to_lowercase()
}
fn is_single_string_keyword<'g, 's>(