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

sile-typesetter / sile / 10866173456

14 Sep 2024 11:07PM UTC coverage: 65.603% (-3.3%) from 68.912%
10866173456

push

github

web-flow
Merge c40733634 into 8bed2e6bb

101 of 1236 new or added lines in 10 files covered. (8.17%)

72 existing lines in 7 files now uncovered.

12300 of 18749 relevant lines covered (65.6%)

5164.31 hits per line

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

46.15
/csl/core/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")
1✔
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)
NEW
13
   local first = luautf8.sub(text, 1, 1)
×
NEW
14
   local rest = luautf8.sub(text, 2)
×
NEW
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 = {
1✔
21
   -- Straightforward
22
   ["lowercase"] = function (text, lang)
NEW
23
      return icu.case(text, lang, "lower")
×
24
   end,
25
   ["uppercase"] = function (text, lang)
NEW
26
      return icu.case(text, lang, "upper")
×
27
   end,
28
   ["capitalize-first"] = capitalizeFirst,
1✔
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,
1✔
35
   ["title"] = capitalizeFirst,
1✔
36

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

45
return casing
1✔
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