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

sile-typesetter / sile / 14384044172

10 Apr 2025 03:07PM UTC coverage: 40.142% (+10.8%) from 29.317%
14384044172

push

github

alerque
Merge branch 'cairo-is-still-in-egypt'

3 of 51 new or added lines in 3 files covered. (5.88%)

302 existing lines in 20 files now uncovered.

6876 of 17129 relevant lines covered (40.14%)

2601.39 hits per line

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

73.58
/core/misc.lua
1
-- TODO: this probably needs deprecating, moved here just to get out of the way so
2
-- typesetters classing works as expected
3
local function typesetNaturally (frame, func)
4
   local saveTypesetter = SILE.typesetter
47✔
5
   if SILE.typesetter.frame then
47✔
6
      SILE.typesetter.frame:leave(SILE.typesetter)
47✔
7
   end
8
   SILE.typesetter = SILE.typesetters.default(frame)
94✔
9
   SILE.settings:temporarily(func)
47✔
10
   SILE.typesetter:leaveHmode()
47✔
11
   SILE.typesetter:chuck()
47✔
12
   SILE.typesetter.frame:leave(SILE.typesetter)
47✔
13
   SILE.typesetter = saveTypesetter
47✔
14
   if SILE.typesetter.frame then
47✔
15
      SILE.typesetter.frame:enter(SILE.typesetter)
47✔
16
   end
17
end
18

19
local function call (command, options, content)
20
   options = options or {}
2,370✔
21
   content = content or {}
2,370✔
22
   if SILE.traceback and type(content) == "table" and not content.lno then
2,370✔
23
      -- This call is from code (no content.lno) and we want to spend the time
24
      -- to determine everything we need about the caller
25
      local caller = debug.getinfo(2, "Sl")
×
26
      content.file, content.lno = caller.short_src, caller.currentline
×
27
   end
28
   local pId = SILE.traceStack:pushCommand(command, content, options)
2,370✔
29
   if not SILE.Commands[command] then
2,370✔
30
      SU.error("Unknown command " .. command)
×
31
   end
32
   local result = SILE.Commands[command](options, content)
2,370✔
33
   SILE.traceStack:pop(pId)
2,370✔
34
   return result
2,370✔
35
end
36

37
local function registerCommand (name, func, help, pack, cheat)
38
   local class = SILE.documentState.documentClass
897✔
39
   if not cheat then
897✔
40
      SU.deprecated(
2✔
41
         "SILE.registerCommand",
1✔
42
         "class:registerCommand / package:registerCommand",
1✔
43
         "0.14.0",
1✔
44
         "0.16.0",
1✔
45
         [[
×
46
            Commands are being scoped to the document classes or packages they are
47
            loaded into rather than using a global registry.
48
         ]]
×
49
      )
1✔
50
   end
51
   -- Shimming until we have all scope cheating removed from core
52
   if not cheat or not class or class.type ~= "class" then
897✔
53
      return SILE.classes.base.registerCommand(nil, name, func, help, pack)
1,046✔
54
   end
UNCOV
55
   return class:registerCommand(name, func, help, pack)
×
56
end
57

58
local function setCommandDefaults (command, options)
59
   local oldCommand = SILE.Commands[command]
×
60
   SILE.Commands[command] = function (defaults, content)
×
61
      for k, v in pairs(options) do
×
62
         defaults[k] = defaults[k] or v
×
63
      end
64
      return oldCommand(defaults, content)
×
65
   end
66
end
67

68
-- TODO: Move to new table entry handler in types.unit
69
local function registerUnit (unit, spec)
70
   -- If a unit exists already, clear it first so we get fresh meta table entries, see #1607
71
   if SILE.types.unit[unit] then
18✔
72
      SILE.types.unit[unit] = nil
×
73
   end
74
   SILE.types.unit[unit] = spec
18✔
75
end
76

77
local function paperSizeParser (size)
78
   SU.deprecated("SILE.paperSizeParser", "SILE.papersize", "0.15.0", "0.16.0")
×
79
   return SILE.papersize(size)
×
80
end
81

82
return {
149✔
83
   typesetNaturally = typesetNaturally,
149✔
84
   call = call,
149✔
85
   registerCommand = registerCommand,
149✔
86
   setCommandDefaults = setCommandDefaults,
149✔
87
   registerUnit = registerUnit,
149✔
88
   paperSizeParser = paperSizeParser,
149✔
89
}
149✔
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