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

sile-typesetter / sile / 10864440887

14 Sep 2024 06:02PM UTC coverage: 58.033% (-10.9%) from 68.912%
10864440887

push

github

web-flow
Merge dea1be4ad into 8bed2e6bb

0 of 1173 new or added lines in 10 files covered. (0.0%)

1202 existing lines in 39 files now uncovered.

10797 of 18605 relevant lines covered (58.03%)

2074.85 hits per line

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

0.0
/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

NEW
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)
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
NEW
20
local casing = {
×
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,
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, _)
NEW
40
      SU.warn("Sentence case is deprecated in CSL 1.0.x (ignored)")
×
NEW
41
      return text
×
42
   end,
43
}
44

NEW
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