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

sile-typesetter / sile / 9507147410

13 Jun 2024 09:40PM UTC coverage: 50.521% (-18.7%) from 69.177%
9507147410

push

github

web-flow
Merge pull request #2062 from alerque/plug-fluent-leak

Link document.language setting more closely with Fluent locale

15 of 15 new or added lines in 3 files covered. (100.0%)

3244 existing lines in 65 files now uncovered.

8586 of 16995 relevant lines covered (50.52%)

4659.09 hits per line

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

0.0
/packages/masters/init.lua
UNCOV
1
local base = require("packages.base")
×
2

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

6
local _currentMaster
7

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

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

33
local function doswitch (frames)
UNCOV
34
   SILE.frames = { page = SILE.frames.page }
×
UNCOV
35
   for id, frame in pairs(frames) do
×
UNCOV
36
      SILE.frames[id] = frame
×
UNCOV
37
      frame:invalidate()
×
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)
UNCOV
55
   if not id then
×
56
      SU.deprecated("class.switchMaster", "class:switchMaster", "0.13.0", "0.15.0")
×
57
   end
UNCOV
58
   _currentMaster = id
×
UNCOV
59
   if not SILE.scratch.masters[id] then
×
60
      SU.error("Can't find master " .. id)
×
61
   end
UNCOV
62
   class.pageTemplate = SILE.scratch.masters[id]
×
UNCOV
63
   SILE.documentState.thisPageTemplate = class.pageTemplate
×
UNCOV
64
   doswitch(SILE.scratch.masters[id].frames)
×
UNCOV
65
   SILE.typesetter:initFrame(SILE.scratch.masters[id].firstContentFrame)
×
66
end
67

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

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

UNCOV
87
function package:registerCommands ()
×
UNCOV
88
   self:registerCommand("define-master-template", function (options, content)
×
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

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

UNCOV
114
   self:registerCommand("switch-master", function (options, _)
×
UNCOV
115
      SU.required(options, "id", "switching master")
×
UNCOV
116
      self.class:switchMaster(options.id)
×
UNCOV
117
   end, "Switches the master for the current page")
×
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}
UNCOV
127
]]
×
128

UNCOV
129
return package
×
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