• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 12272864087

11 Dec 2024 08:55AM UTC coverage: 29.607% (-41.0%) from 70.614%
12272864087

push

github

web-flow
Merge 95cccf286 into f394f608c

5834 of 19705 relevant lines covered (29.61%)

429.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/bibtex/csl/utils/casing.lua
1
--- Casing functions for CSL locales.
2
--
3
-- @copyright License: MIT (c) 2024 Omikhleia
4
--
5
-- Objectives: provide functions to handle text casing in CSL locales.
6
--
7

8
local icu = require("justenoughicu")
×
9
-- N.B. We don't use the textcase package here:
10
-- The language is a BCP47 identifier from the CSL locale.
11

12
local capitalizeFirst = function (text, lang)
13
   local first = luautf8.sub(text, 1, 1)
×
14
   local rest = luautf8.sub(text, 2)
×
15
   return icu.case(first, lang, "upper") .. rest
×
16
end
17

18
--- Text casing methods for CSL.
19
-- @table casing methods for lower, upper, capitalize-first, capitalize-all, title, sentence
20
local casing = {
×
21
   -- Straightforward
22
   ["lowercase"] = function (text, lang)
23
      return icu.case(text, lang, "lower")
×
24
   end,
25
   ["uppercase"] = function (text, lang)
26
      return icu.case(text, lang, "upper")
×
27
   end,
28
   ["capitalize-first"] = capitalizeFirst,
29

30
   -- Opinionated: even ICU does not really handle this well.
31
   -- It does not have good support for exceptions (small words, prepositions,
32
   -- articles), etc. in most languages
33
   -- So fallback to capitalize-first.
34
   ["capitalize-all"] = capitalizeFirst,
35
   ["title"] = capitalizeFirst,
36

37
   -- Deprecated.
38
   -- Let's not bother with it.
39
   ["sentence"] = function (text, _)
40
      SU.warn("Sentence case is deprecated in CSL 1.0.x (ignored)")
×
41
      return text
×
42
   end,
43
}
44

45
return casing
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc