From 51429e31553f0cfc7db55db363b5d1c3a1086f44 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 11 Oct 2023 18:50:22 -0400 Subject: [PATCH] Handle optval when translating names. --- src/parser/affiliated_keyword.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/parser/affiliated_keyword.rs b/src/parser/affiliated_keyword.rs index dc43820..88cdabd 100644 --- a/src/parser/affiliated_keyword.rs +++ b/src/parser/affiliated_keyword.rs @@ -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>(