toLocatorMap: store keys as lowercase.

We want to do a case-insensitive comparison when parsing
locators, so that e.g. both `Chap.` and `chap.` work.

Previously we lowercase terms when doing the lookup,
but they weren't lowercased in the map itself, which
led to locator-detection breaking for German (where the
terms have uppercase letters).

See
https://groups.google.com/d/msgid/pandoc-discuss/1dd44886-7b79-4e5f-97ec-57b91113df36n%40googlegroups.com
This commit is contained in:
John MacFarlane 2022-01-08 16:54:00 -08:00
parent 268bec1808
commit 2b51f54e19

View file

@ -276,7 +276,9 @@ toLocatorMap locale =
go tname locmap =
case M.lookup tname (localeTerms locale) of
Nothing -> locmap
Just ts -> foldr (\x -> M.insert (snd x) tname) locmap ts
Just ts -> foldr (\x -> M.insert (T.toCaseFold $ snd x) tname) locmap ts
-- we store keys in "case-folded" (lowercase) form, so that both
-- "Chap." and "chap." will match, for example.
locatorTerms :: [Text]
locatorTerms =