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

sile-typesetter / sile / 14334874064

08 Apr 2025 01:31PM UTC coverage: 59.535% (-3.5%) from 63.083%
14334874064

push

github

web-flow
Merge pull request #2259 from Omikhleia/fix-hyphen-minima

Fix hyphen minima logic and update several hyphenation patterns

21 of 34 new or added lines in 14 files covered. (61.76%)

941 existing lines in 51 files now uncovered.

12856 of 21594 relevant lines covered (59.54%)

2362.76 hits per line

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

60.0
/core/require.lua
1
local function require_ (dependency, pathprefix, deprecation_ack)
2
   if pathprefix and not deprecation_ack then
67✔
3
      local notice = string.format(
×
4
         [[
×
5
  Please don't use the path prefix mechanism; it was intended to provide
6
  alternate paths to override core components but never worked well and is
7
  causing portability problems. Just use Lua idiomatic module loading:
8
      SILE.require("%s", "%s") → SILE.require("%s.%s")]],
9
         dependency,
10
         pathprefix,
11
         pathprefix,
12
         dependency
13
      )
14
      SU.deprecated("SILE.require", "SILE.require", "0.13.0", nil, notice)
×
15
   end
16
   dependency = dependency:gsub(".lua$", "")
67✔
17
   local status, lib
18
   if pathprefix then
67✔
19
      -- Note this is not a *path*, it is a module identifier:
20
      -- https://github.com/sile-typesetter/sile/issues/1861
21
      status, lib = pcall(require, pl.stringx.join(".", { pathprefix, dependency }))
134✔
22
   end
23
   if not status then
67✔
UNCOV
24
      local prefixederror = lib
×
UNCOV
25
      status, lib = pcall(require, dependency)
×
UNCOV
26
      if not status then
×
27
         SU.error(
×
28
            ("Unable to find module '%s'%s"):format(
×
29
               dependency,
30
               SILE.traceback and ((pathprefix and "\n  " .. prefixederror or "") .. "\n  " .. lib) or ""
×
31
            )
32
         )
33
      end
34
   end
35
   local class = SILE.documentState.documentClass
67✔
36
   if not class and not deprecation_ack then
67✔
37
      SU.warn(string.format(
×
38
         [[
×
39
            SILE.require() is only supported in documents, packages, or class init
40

41
            It will not function fully before the class is instantiated. Please just use
42
            the Lua require() function directly:
43

44
              SILE.require("%s") → require("%s")
45
         ]],
46
         dependency,
47
         dependency
48
      ))
49
   end
50
   if type(lib) == "table" and class then
67✔
UNCOV
51
      if lib.type == "package" then
×
UNCOV
52
         lib(class)
×
53
      else
54
         class:initPackage(lib)
×
55
      end
56
   end
57
   return lib
67✔
58
end
59

60
local function resolveFile (filename, pathprefix)
61
   local candidates = {}
70✔
62
   -- Start with the raw file name as given prefixed with a path if requested
63
   if pathprefix then
70✔
64
      candidates[#candidates + 1] = pl.path.join(pathprefix, "?")
×
65
   end
66
   -- Also check the raw file name without a path
67
   candidates[#candidates + 1] = "?"
70✔
68
   -- Iterate through the directory of the master file, the SILE_PATH variable, and the current directory
69
   -- Check for prefixed paths first, then the plain path in that fails
70
   if SILE.masterDir then
70✔
71
      for path in SU.gtoke(SILE.masterDir .. ";" .. tostring(os.getenv("SILE_PATH")), ";") do
630✔
72
         if path.string and path.string ~= "nil" then
490✔
73
            if pathprefix then
280✔
74
               candidates[#candidates + 1] = pl.path.join(path.string, pathprefix, "?")
×
75
            end
76
            candidates[#candidates + 1] = pl.path.join(path.string, "?")
560✔
77
         end
78
      end
79
   end
80
   -- Return the first candidate that exists, also checking the .sil suffix
81
   local path = table.concat(candidates, ";")
70✔
82
   local resolved, err = package.searchpath(filename, path, "/")
70✔
83
   if resolved then
70✔
84
      if SILE.makeDeps then
70✔
85
         SILE.makeDeps:add(resolved)
70✔
86
      end
87
   elseif SU.debugging("paths") then
×
88
      SU.debug("paths", ("Unable to find file '%s': %s"):format(filename, err))
×
89
   end
90
   return resolved
70✔
91
end
92

93
return {
131✔
94
   require = require_,
131✔
95
   resolveFile = resolveFile,
131✔
96
}
131✔
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