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

sile-typesetter / sile / 11573668360

29 Oct 2024 12:17PM UTC coverage: 58.059% (-9.6%) from 67.697%
11573668360

push

github

web-flow
Merge pull request #2139 from Omikhleia/fix-math-tex-limits

TeX-math limits and other commands behaving as big ops

6 of 11 new or added lines in 1 file covered. (54.55%)

1797 existing lines in 50 files now uncovered.

10360 of 17844 relevant lines covered (58.06%)

3713.48 hits per line

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

58.97
/packages/masters/init.lua
1
local base = require("packages.base")
4✔
2

3
local package = pl.class(base)
4✔
4
package._name = "masters"
4✔
5

6
local _currentMaster
7

8
local function defineMaster (_, options)
9
   SU.required(options, "id", "defining master")
4✔
10
   SU.required(options, "frames", "defining master")
4✔
11
   SU.required(options, "firstContentFrame", "defining master")
4✔
12
   SILE.scratch.masters[options.id] = { frames = {}, firstContentFrame = nil }
4✔
13
   for frame, spec in pairs(options.frames) do
20✔
14
      spec.id = frame
16✔
15
      if spec.solve then
16✔
16
         SILE.scratch.masters[options.id].frames[frame] = spec
×
17
      else
18
         SILE.scratch.masters[options.id].frames[frame] = SILE.newFrame(spec)
32✔
19
      end
20
   end
21
   SILE.scratch.masters[options.id].firstContentFrame =
4✔
22
      SILE.scratch.masters[options.id].frames[options.firstContentFrame]
4✔
23
end
24

25
local function defineMasters (class, list)
26
   if list then
4✔
27
      for i = 1, #list do
8✔
28
         defineMaster(class, list[i])
4✔
29
      end
30
   end
31
end
32

33
local function doswitch (frames)
34
   SILE.frames = { page = SILE.frames.page }
15✔
35
   for id, frame in pairs(frames) do
75✔
36
      SILE.frames[id] = frame
60✔
37
      frame:invalidate()
60✔
38
   end
39
end
40

41
local function switchMasterOnePage (_, id)
UNCOV
42
   if not id then
×
43
      SU.deprecated("class.switchMasterOnePage", "class:switchMasterOnePage", "0.13.0", "0.15.0")
×
44
   end
UNCOV
45
   if not SILE.scratch.masters[id] then
×
46
      SU.error("Can't find master " .. id)
×
47
   end
UNCOV
48
   SILE.documentState.thisPageTemplate = SILE.scratch.masters[id]
×
UNCOV
49
   doswitch(SILE.scratch.masters[id].frames)
×
UNCOV
50
   SILE.typesetter:chuck()
×
UNCOV
51
   SILE.typesetter:initFrame(SILE.scratch.masters[id].firstContentFrame)
×
52
end
53

54
local function switchMaster (class, id)
55
   if not id then
15✔
56
      SU.deprecated("class.switchMaster", "class:switchMaster", "0.13.0", "0.15.0")
×
57
   end
58
   _currentMaster = id
15✔
59
   if not SILE.scratch.masters[id] then
15✔
60
      SU.error("Can't find master " .. id)
×
61
   end
62
   class.pageTemplate = SILE.scratch.masters[id]
15✔
63
   SILE.documentState.thisPageTemplate = class.pageTemplate
15✔
64
   doswitch(SILE.scratch.masters[id].frames)
15✔
65
   SILE.typesetter:initFrame(SILE.scratch.masters[id].firstContentFrame)
15✔
66
end
67

68
local function currentMaster (_)
69
   return _currentMaster
×
70
end
71

72
function package:_init (options)
4✔
73
   base._init(self, options)
4✔
74
   if not SILE.scratch.masters then
4✔
75
      SILE.scratch.masters = {}
4✔
76
   end
77
   self:export("switchMasterOnePage", switchMasterOnePage)
4✔
78
   self:export("switchMaster", switchMaster)
4✔
79
   self:export("defineMaster", defineMaster)
4✔
80
   self:export("defineMasters", defineMasters)
4✔
81
   self:export("currentMaster", currentMaster)
4✔
82
   if options then
4✔
83
      self.class:defineMasters(options)
4✔
84
   end
85
end
86

87
function package:registerCommands ()
4✔
88
   self:registerCommand("define-master-template", function (options, content)
8✔
UNCOV
89
      SU.required(options, "id", "defining a master")
×
UNCOV
90
      SU.required(options, "first-content-frame", "defining a master")
×
91
      -- Subvert the <frame> functionality from baseclass
UNCOV
92
      local spare = SILE.documentState.thisPageTemplate.frames
×
UNCOV
93
      local sp2 = SILE.frames
×
UNCOV
94
      SILE.frames = { page = SILE.frames.page }
×
UNCOV
95
      SILE.documentState.thisPageTemplate.frames = {}
×
UNCOV
96
      SILE.process(content)
×
UNCOV
97
      SILE.scratch.masters[options.id] = {}
×
UNCOV
98
      SILE.scratch.masters[options.id].frames = SILE.documentState.thisPageTemplate.frames
×
UNCOV
99
      if not SILE.scratch.masters[options.id].frames[options["first-content-frame"]] then
×
100
         SU.error("first-content-frame " .. options["first-content-frame"] .. " not found")
×
101
      end
UNCOV
102
      SILE.scratch.masters[options.id].firstContentFrame =
×
UNCOV
103
         SILE.scratch.masters[options.id].frames[options["first-content-frame"]]
×
UNCOV
104
      SILE.documentState.thisPageTemplate.frames = spare
×
UNCOV
105
      SILE.frames = sp2
×
106
   end)
107

108
   self:registerCommand("switch-master-one-page", function (options, _)
8✔
UNCOV
109
      SU.required(options, "id", "switching master")
×
UNCOV
110
      self.class:switchMasterOnePage(options.id)
×
UNCOV
111
      SILE.typesetter:leaveHmode()
×
112
   end, "Switches the master for the current page")
4✔
113

114
   self:registerCommand("switch-master", function (options, _)
8✔
UNCOV
115
      SU.required(options, "id", "switching master")
×
UNCOV
116
      self.class:switchMaster(options.id)
×
117
   end, "Switches the master for the current page")
4✔
118
end
119

120
package.documentation = [[
121
\begin{document}
122
The masters functionality is also itself an add-on package.
123
It allows a class to define sets of frames and switch between them either temporarily or permanently.
124
It defines the commands \autodoc:command{\define-master-template} (which is patterned on the \autodoc:command{\pagetemplate} function we will meet in Chapter 8), \autodoc:command{\switch-master}, and \autodoc:command{\switch-master-one-page}.
125
See \code{tests/masters.sil} for more about this package.
126
\end{document}
127
]]
4✔
128

129
return package
4✔
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