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

sile-typesetter / sile / 6941442205

21 Nov 2023 08:56AM UTC coverage: 63.58% (+1.3%) from 62.266%
6941442205

Pull #1904

github

web-flow
Merge pull request #1891 from sile-typesetter/ot-tate
Pull Request #1904: Merge develop into master (commit to next release being breaking)

67 of 198 new or added lines in 20 files covered. (33.84%)

171 existing lines in 13 files now uncovered.

9907 of 15582 relevant lines covered (63.58%)

6710.82 hits per line

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

61.63
/classes/book.lua
1
local plain = require("classes.plain")
33✔
2

3
local class = pl.class(plain)
33✔
4
class._name = "book"
33✔
5

6
class.defaultFrameset = {
33✔
7
  content = {
33✔
8
    left = "8.3%pw",
9
    right = "86%pw",
10
    top = "11.6%ph",
11
    bottom = "top(footnotes)"
×
12
  },
33✔
13
  folio = {
33✔
14
    left = "left(content)",
15
    right = "right(content)",
16
    top = "bottom(footnotes)+3%ph",
17
    bottom = "bottom(footnotes)+5%ph"
×
18
  },
33✔
19
  runningHead = {
33✔
20
    left = "left(content)",
21
    right = "right(content)",
22
    top = "top(content)-8%ph",
23
    bottom = "top(content)-3%ph"
×
24
  },
33✔
25
  footnotes = {
33✔
26
    left = "left(content)",
27
    right = "right(content)",
28
    height = "0",
29
    bottom = "83.3%ph"
×
30
  }
33✔
31
}
33✔
32

33
function class:_init (options)
33✔
34
  plain._init(self, options)
33✔
35
  self:loadPackage("counters")
33✔
36
  self:loadPackage("masters", {{
66✔
37
      id = "right",
38
      firstContentFrame = self.firstContentFrame,
33✔
39
      frames = self.defaultFrameset
33✔
40
    }})
33✔
41
  self:loadPackage("twoside", {
33✔
42
      oddPageMaster = "right",
43
      evenPageMaster = "left"
×
44
    })
45
  self:loadPackage("tableofcontents")
33✔
46
  self:loadPackage("footnotes", {
66✔
47
      insertInto = "footnotes",
48
      stealFrom = { "content" }
33✔
49
    })
50
  if not SILE.scratch.headers then SILE.scratch.headers = {} end
33✔
51
end
52

53
function class:endPage ()
33✔
54
  if not SILE.scratch.headers.skipthispage then
69✔
55
    if self:oddPage() and SILE.scratch.headers.right then
132✔
56
      SILE.typesetNaturally(SILE.getFrame("runningHead"), function ()
4✔
57
        SILE.settings:toplevelState()
2✔
58
        SILE.settings:set("current.parindent", SILE.nodefactory.glue())
4✔
59
        SILE.settings:set("document.lskip", SILE.nodefactory.glue())
4✔
60
        SILE.settings:set("document.rskip", SILE.nodefactory.glue())
4✔
61
        -- SILE.settings:set("typesetter.parfillskip", SILE.nodefactory.glue())
62
        SILE.process(SILE.scratch.headers.right)
2✔
63
        SILE.call("par")
2✔
64
      end)
65
    elseif not self:oddPage() and SILE.scratch.headers.left then
128✔
66
      SILE.typesetNaturally(SILE.getFrame("runningHead"), function ()
×
67
        SILE.settings:toplevelState()
×
68
        SILE.settings:set("current.parindent", SILE.nodefactory.glue())
×
69
        SILE.settings:set("document.lskip", SILE.nodefactory.glue())
×
70
        SILE.settings:set("document.rskip", SILE.nodefactory.glue())
×
71
        -- SILE.settings:set("typesetter.parfillskip", SILE.nodefactory.glue())
72
        SILE.process(SILE.scratch.headers.left)
×
73
        SILE.call("par")
×
74
      end)
75
    end
76
  end
77
  SILE.scratch.headers.skipthispage = false
69✔
78
  return plain.endPage(self)
69✔
79
end
80

81
function class:finish ()
33✔
82
  local ret = plain.finish(self)
33✔
83
  return ret
33✔
84
end
85

86
function class:registerCommands ()
33✔
87

88
  plain.registerCommands(self)
33✔
89

90
  self:registerCommand("left-running-head", function (_, content)
66✔
UNCOV
91
    local closure = SILE.settings:wrap()
×
UNCOV
92
    SILE.scratch.headers.left = function () closure(content) end
×
93
  end, "Text to appear on the top of the left page")
33✔
94

95
  self:registerCommand("right-running-head", function (_, content)
66✔
96
    local closure = SILE.settings:wrap()
3✔
97
    SILE.scratch.headers.right = function () closure(content) end
7✔
98
  end, "Text to appear on the top of the right page")
36✔
99

100
  self:registerCommand("book:sectioning", function (options, content)
66✔
101
    local level = SU.required(options, "level", "book:sectioning")
2✔
102
    local number
103
    if SU.boolean(options.numbering, true) then
4✔
104
      SILE.call("increment-multilevel-counter", { id = "sectioning", level = level })
2✔
105
      number = self.packages.counters:formatMultilevelCounter(self:getMultilevelCounter("sectioning"))
6✔
106
    end
107
    if SU.boolean(options.toc, true) then
4✔
108
      SILE.call("tocentry", { level = level, number = number }, SU.subContent(content))
4✔
109
    end
110
    if SU.boolean(options.numbering, true) then
4✔
111
      if options.msg then
2✔
UNCOV
112
        SILE.call("fluent", { number = number }, { options.msg })
×
113
      else
114
        SILE.call("show-multilevel-counter", { id = "sectioning" })
2✔
115
      end
116
    end
117
  end)
118

119
  self:registerCommand("book:chapter:post", function (_, _)
66✔
UNCOV
120
    SILE.call("par")
×
UNCOV
121
    SILE.call("noindent")
×
122
  end)
123

124
  self:registerCommand("book:section:post", function (_, _)
66✔
125
    SILE.process({ " " })
2✔
126
  end)
127

128
  self:registerCommand("book:subsection:post", function (_, _)
66✔
129
    SILE.process({ " " })
×
130
  end)
131

132
  self:registerCommand("book:left-running-head-font", function (_, content)
66✔
133
    SILE.call("font", { size = "9pt" }, content)
×
134
  end)
135

136
  self:registerCommand("book:right-running-head-font", function (_, content)
66✔
137
    SILE.call("font", { size = "9pt", style = "Italic" }, content)
1✔
138
  end)
139

140
  self:registerCommand("chapter", function (options, content)
66✔
UNCOV
141
    SILE.typesetter:leaveHmode()
×
UNCOV
142
    SILE.call("open-spread", { double = false })
×
UNCOV
143
    SILE.call("noindent")
×
UNCOV
144
    SILE.scratch.headers.right = nil
×
UNCOV
145
    SILE.call("set-counter", { id = "footnote", value = 1 })
×
UNCOV
146
    SILE.call("book:chapterfont", {}, function ()
×
UNCOV
147
      SILE.call("book:sectioning", {
×
148
        numbering = options.numbering,
149
        toc = options.toc,
150
        level = 1,
151
        msg = "book-chapter-title"
×
UNCOV
152
      }, content)
×
153
    end)
UNCOV
154
    local lang = SILE.settings:get("document.language")
×
UNCOV
155
    local postcmd = "book:chapter:post"
×
UNCOV
156
    if SILE.Commands[postcmd .. ":" .. lang] then
×
UNCOV
157
      postcmd = postcmd .. ":" .. lang
×
158
    end
UNCOV
159
    SILE.call(postcmd)
×
UNCOV
160
    SILE.call("book:chapterfont", {}, content)
×
UNCOV
161
    SILE.call("left-running-head", {}, function ()
×
162
      SILE.settings:temporarily(function ()
×
163
        SILE.call("book:left-running-head-font", {}, content)
×
164
      end)
165
    end)
UNCOV
166
    SILE.call("bigskip")
×
UNCOV
167
    SILE.call("nofoliothispage")
×
168
    -- English typography (notably) expects the first paragraph under a section
169
    -- not to be indented. Frenchies, don't use this class :)
UNCOV
170
    SILE.call("noindent")
×
171
  end, "Begin a new chapter")
33✔
172

173
  self:registerCommand("section", function (options, content)
66✔
174
    SILE.typesetter:leaveHmode()
2✔
175
    SILE.call("goodbreak")
2✔
176
    SILE.call("bigskip")
2✔
177
    SILE.call("noindent")
2✔
178
    SILE.call("book:sectionfont", {}, function ()
4✔
179
      SILE.call("book:sectioning", {
4✔
180
        numbering = options.numbering,
2✔
181
        toc = options.toc,
2✔
182
        level = 2
×
183
      }, content)
2✔
184
      local lang = SILE.settings:get("document.language")
2✔
185
      local postcmd = "book:section:post"
2✔
186
      if SILE.Commands[postcmd .. ":" .. lang] then
2✔
187
        postcmd = postcmd .. ":" .. lang
×
188
      end
189
      SILE.call(postcmd)
2✔
190
      SILE.process(content)
2✔
191
    end)
192
    if not SILE.scratch.counters.folio.off then
2✔
193
      SILE.call("right-running-head", {}, function ()
4✔
194
        SILE.call("book:right-running-head-font", {}, function ()
2✔
195
          SILE.call("rightalign", {}, function ()
2✔
196
            SILE.settings:temporarily(function ()
2✔
197
              if SU.boolean(options.numbering, true) then
2✔
198
                SILE.call("show-multilevel-counter", { id = "sectioning", level = 2 })
1✔
199
                SILE.typesetter:typeset(" ")
1✔
200
              end
201
              SILE.process(content)
1✔
202
            end)
203
          end)
204
        end)
205
      end)
206
    end
207
    SILE.call("novbreak")
2✔
208
    SILE.call("bigskip")
2✔
209
    SILE.call("novbreak")
2✔
210
    -- English typography (notably) expects the first paragraph under a section
211
    -- not to be indented. Frenchies, don't use this class :)
212
    SILE.call("noindent")
2✔
213
    SILE.typesetter:inhibitLeading()
2✔
214
  end, "Begin a new section")
35✔
215

216
  self:registerCommand("subsection", function (options, content)
66✔
217
    SILE.typesetter:leaveHmode()
×
218
    SILE.call("goodbreak")
×
219
    SILE.call("noindent")
×
220
    SILE.call("medskip")
×
221
    SILE.call("book:subsectionfont", {}, function ()
×
222
      SILE.call("book:sectioning", {
×
223
            numbering = options.numbering,
224
            toc = options.toc,
225
            level = 3
×
226
          }, content)
×
227
      local lang = SILE.settings:get("document.language")
×
228
      local postcmd = "book:subsection:post"
×
229
      if SILE.Commands[postcmd .. ":" .. lang] then
×
230
        postcmd = postcmd .. ":" .. lang
×
231
      end
232
      SILE.call(postcmd)
×
233
      SILE.process(content)
×
234
    end)
235
    SILE.typesetter:leaveHmode()
×
236
    SILE.call("novbreak")
×
237
    SILE.call("medskip")
×
238
    SILE.call("novbreak")
×
239
    -- English typography (notably) expects the first paragraph under a section
240
    -- not to be indented. Frenchies, don't use this class :)
241
    SILE.call("noindent")
×
242
    SILE.typesetter:inhibitLeading()
×
243
  end, "Begin a new subsection")
33✔
244

245
  self:registerCommand("book:chapterfont", function (_, content)
66✔
UNCOV
246
    SILE.settings:temporarily(function ()
×
UNCOV
247
      SILE.call("font", { weight = 800, size = "22pt" }, content)
×
248
    end)
249
  end)
250
  self:registerCommand("book:sectionfont", function (_, content)
66✔
251
    SILE.settings:temporarily(function ()
4✔
252
      SILE.call("font", { weight = 800, size = "15pt" }, content)
2✔
253
    end)
254
  end)
255

256
  self:registerCommand("book:subsectionfont", function (_, content)
66✔
257
    SILE.settings:temporarily(function ()
×
258
      SILE.call("font", { weight = 800, size = "12pt" }, content)
×
259
    end)
260
  end)
261

262
end
263

264
return class
33✔
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