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

sile-typesetter / sile / 14502192980

16 Apr 2025 08:26PM UTC coverage: 57.267% (-5.4%) from 62.627%
14502192980

push

github

alerque
chore(packages): Remove unused package interdependency, url doesn't need verbatim

Reported-by: Omikhleia <didier.willis@gmail.com>

12352 of 21569 relevant lines covered (57.27%)

871.56 hits per line

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

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

19
local function call (command, options, content)
20
   options = options or {}
631✔
21
   content = content or {}
631✔
22
   if SILE.traceback and type(content) == "table" and not content.lno then
631✔
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)
631✔
29
   if not SILE.Commands[command] then
631✔
30
      SU.error("Unknown command " .. command)
×
31
   end
32
   local result = SILE.Commands[command](options, content)
631✔
33
   SILE.traceStack:pop(pId)
631✔
34
   return result
631✔
35
end
36

37
local function registerCommand (name, func, help, pack, cheat)
38
   local class = SILE.documentState.documentClass
301✔
39
   if not cheat then
301✔
40
      SU.deprecated(
×
41
         "SILE.registerCommand",
42
         "class:registerCommand / package:registerCommand",
43
         "0.14.0",
44
         "0.16.0",
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
      )
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
301✔
53
      return SILE.classes.base.registerCommand(nil, name, func, help, pack)
351✔
54
   end
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
5✔
72
      SILE.types.unit[unit] = nil
×
73
   end
74
   SILE.types.unit[unit] = spec
5✔
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 {
50✔
83
   typesetNaturally = typesetNaturally,
50✔
84
   call = call,
50✔
85
   registerCommand = registerCommand,
50✔
86
   setCommandDefaults = setCommandDefaults,
50✔
87
   registerUnit = registerUnit,
50✔
88
   paperSizeParser = paperSizeParser,
50✔
89
}
50✔
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

© 2025 Coveralls, Inc