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

sile-typesetter / sile / 9304049654

30 May 2024 02:12PM UTC coverage: 60.021% (-14.7%) from 74.707%
9304049654

push

github

web-flow
Merge 1a26b4f22 into a1fd105f8

6743 of 12900 new or added lines in 186 files covered. (52.27%)

347 existing lines in 49 files now uncovered.

10311 of 17179 relevant lines covered (60.02%)

3307.34 hits per line

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

28.57
/core/utilities/sorting.lua
1
--- Table sorting with language-dependent collation.
2
-- @module SU.sorting
3

4
local icu = require("justenoughicu")
208✔
5

6
local collatedSort = {
208✔
7
   -- No ICU for language "und", fallback to 'natural' table.sort
8
   und = function (t, _)
NEW
9
      table.sort(t)
×
10
   end,
11
}
12

13
setmetatable(collatedSort, {
416✔
14
   __call = function (self, t, options)
NEW
15
      local lang = SILE.settings:get("document.language")
×
NEW
16
      if self[lang] and type(self[lang]) == "function" then
×
17
         -- Allow overriding ICU for some languages, typically "und"
NEW
18
         return self[lang](t, options)
×
19
      end
20

NEW
21
      if self[lang] and type(self[lang]) == "table" then
×
22
         -- Allow customizing the default collation options for some languages
NEW
23
         options = options or self[lang]
×
24
      end
25
      -- Be efficient: create the collator once before sorting.
26
      -- I don't think we need to cache it, still.
NEW
27
      local collator = icu.collation_create(lang, options or {})
×
NEW
28
      table.sort(t, function (s1, s2)
×
NEW
29
         return icu.compare(collator, s1, s2)
×
30
      end)
NEW
31
      icu.collation_destroy(collator)
×
32
   end,
33
})
34

35
return collatedSort
208✔
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