Skip to content

Commit

Permalink
test(classes): Redo class tests with Penlight class model
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed May 10, 2022
1 parent f1b8a57 commit 41ddeab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
17 changes: 10 additions & 7 deletions tests/classes/testsidenote.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
local plain = SILE.require("plain", "classes")
local testsidenote = plain { id = "testsidenote" }
local plain = require("classes.plain")
local testsidenote = pl.class(plain)
testsidenote._name = "testsidenote"

local gutterWidth = "3%pw"

function testsidenote:init ()
function testsidenote:_init (options)
plain._init(self, options)
self:declareFrame("contentA", {left = "left(content)", right = "left(gutter)", top = "top(content)", bottom = "bottom(content)" })
self:declareFrame("sidenotes", {left = "right(gutter)", width="width(contentA) * 2 / 3", right = "right(content)", top = "top(content)", bottom = "bottom(content)", balanced = true })
self:declareFrame("gutter", {left = "right(contentA)", right = "left(sidenotes)", width = gutterWidth })
self.pageTemplate.firstContentFrame = self.pageTemplate.frames["contentA"]
local insertions = SILE.require("packages/insertions")
SILE.require("packages/footnotes")
insertions.exports:initInsertionClass("footnote", {
self:loadPackage("insertions")
self:loadPackage("footnotes")
self:initInsertionClass("footnote", {
maxHeight = SILE.length("75%ph"):absolute(),
topBox = SILE.nodefactory.zerovglue(),
interInsertionSkip = SILE.length("1ex"),
insertInto = { frame = "sidenotes", ratio = 0 },
stealFrom = { },
})
return plain.init(self)
self:post_init()
return self
end

return testsidenote
11 changes: 7 additions & 4 deletions tests/classes/testtwocol.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
local plain = SILE.require("plain", "classes")
local testtwocols = plain { id = "testtwocols" }
local plain = require("classes.plain")
local testtwocols = pl.class(plain)
testtwocols._name = "testtwocols"

local gutterWidth = "3%pw"

testtwocols.defaultFrameset = {}
testtwocols.firstContentFrame = "contentA"

testtwocols.init = function(self)
function testtwocols:_init (options)
plain._init(self, options)
self:declareFrame("contentA", {left = "left(content)", right = "left(gutter)", top = "5%ph", bottom = "83.3%ph", next = "contentB", balanced = true })
self:declareFrame("contentB", {left = "right(gutter)", width="width(contentA) * 2 / 3", right = "right(content)", top = "5%ph", bottom = "top(footnotes)", balanced = true })
self:declareFrame("gutter", {left = "right(contentA)", right = "left(contentB)", width = gutterWidth })
self:declareFrame("footnotes", { left="left(contentB)", right = "right(contentB)", height = "0", bottom="83.3%ph"})
self:loadPackage("footnotes", { insertInto = "footnotes", stealFrom = { contentB = 1 } } )
return plain.init(self)
self:post_init()
return self
end

return testtwocols

0 comments on commit 41ddeab

Please sign in to comment.