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

sile-typesetter / sile / 14284237390

05 Apr 2025 05:33PM UTC coverage: 63.158% (+31.8%) from 31.375%
14284237390

push

github

web-flow
Merge pull request #2248 from alerque/class-warfare

Normalize module layout across all module types

257 of 350 new or added lines in 14 files covered. (73.43%)

71 existing lines in 11 files now uncovered.

13670 of 21644 relevant lines covered (63.16%)

3070.68 hits per line

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

75.47
/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
87✔
5
   if SILE.typesetter.frame then
87✔
6
      SILE.typesetter.frame:leave(SILE.typesetter)
87✔
7
   end
8
   SILE.typesetter = SILE.typesetters.default(frame)
174✔
9
   SILE.settings:temporarily(func)
87✔
10
   SILE.typesetter:leaveHmode()
87✔
11
   SILE.typesetter:chuck()
87✔
12
   SILE.typesetter.frame:leave(SILE.typesetter)
87✔
13
   SILE.typesetter = saveTypesetter
87✔
14
   if SILE.typesetter.frame then
87✔
15
      SILE.typesetter.frame:enter(SILE.typesetter)
87✔
16
   end
17
end
18

19
local function call (command, options, content)
20
   options = options or {}
4,596✔
21
   content = content or {}
4,596✔
22
   if SILE.traceback and type(content) == "table" and not content.lno then
4,596✔
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
NEW
25
      local caller = debug.getinfo(2, "Sl")
×
NEW
26
      content.file, content.lno = caller.short_src, caller.currentline
×
27
   end
28
   local pId = SILE.traceStack:pushCommand(command, content, options)
4,596✔
29
   if not SILE.Commands[command] then
4,596✔
NEW
30
      SU.error("Unknown command " .. command)
×
31
   end
32
   local result = SILE.Commands[command](options, content)
4,596✔
33
   SILE.traceStack:pop(pId)
4,596✔
34
   return result
4,596✔
35
end
36

37
local function registerCommand (name, func, help, pack, cheat)
38
   local class = SILE.documentState.documentClass
1,855✔
39
   if not cheat then
1,855✔
40
      SU.deprecated(
20✔
41
         "SILE.registerCommand",
10✔
42
         "class:registerCommand / package:registerCommand",
10✔
43
         "0.14.0",
10✔
44
         "0.16.0",
10✔
NEW
45
         [[
×
46
            Commands are being scoped to the document classes or packages they are
47
            loaded into rather than using a global registry.
NEW
48
         ]]
×
49
      )
10✔
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
1,855✔
53
      return SILE.classes.base.registerCommand(nil, name, func, help, pack)
2,159✔
54
   end
55
   return class:registerCommand(name, func, help, pack)
2✔
56
end
57

58
local function setCommandDefaults (command, options)
NEW
59
   local oldCommand = SILE.Commands[command]
×
NEW
60
   SILE.Commands[command] = function (defaults, content)
×
NEW
61
      for k, v in pairs(options) do
×
NEW
62
         defaults[k] = defaults[k] or v
×
63
      end
NEW
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
19✔
NEW
72
      SILE.types.unit[unit] = nil
×
73
   end
74
   SILE.types.unit[unit] = spec
19✔
75
end
76

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

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