Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML outputter #3

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
40 changes: 40 additions & 0 deletions classes/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,33 @@ end
function class:setOptions (options)
options = options or {}
options.papersize = options.papersize or "a4"
-- BEGIN SILEX FULL BLEED AND PAGE SIZE
options.bleed = options.bleed or "0"
-- END SILEX FULL BLEED AND PAGE SIZE
for option, value in pairs(options) do
self.options[option] = value
end

-- BEGIN SILEX FULL BLEED AND PAGE SIZE
if not SILE.documentState.sheetSize then
SILE.documentState.sheetSize = {
SILE.documentState.paperSize[1],
SILE.documentState.paperSize[2]
}
end
if SILE.documentState.sheetSize[1] < SILE.documentState.paperSize[1]
or SILE.documentState.sheetSize[2] < SILE.documentState.paperSize[2] then
SU.error("Sheet size shall not be smaller than the paper size")
end
if SILE.documentState.sheetSize[1] < SILE.documentState.paperSize[1] + SILE.documentState.bleed then
SU.debug("frames", "Sheet size width augmented to take page bleed into account")
SILE.documentState.sheetSize[1] = SILE.documentState.paperSize[1] + SILE.documentState.bleed
end
if SILE.documentState.sheetSize[2] < SILE.documentState.paperSize[2] + SILE.documentState.bleed then
SU.debug("frames", "Sheet size height augmented to take page bleed into account")
SILE.documentState.sheetSize[2] = SILE.documentState.paperSize[2] + SILE.documentState.bleed
end
-- END SILEX FULL BLEED AND PAGE SIZE
end

function class:declareOption (option, setter)
Expand Down Expand Up @@ -120,6 +144,22 @@ function class:declareOptions ()
end
return self.papersize
end)
-- BEGIN SILEX FULL BLEED AND PAGE SIZE
self:declareOption("sheetsize", function (_, size)
if size then
self.sheetsize = size
SILE.documentState.sheetSize = SILE.papersize(size)
end
return self.sheetsize
end)
self:declareOption("bleed", function (_, dimen)
if dimen then
self.bleed = dimen
SILE.documentState.bleed = SU.cast("measurement", dimen):tonumber()
end
return self.bleed
end)
-- END SILEX FULL BLEED AND PAGE SIZE
end

function class.declareSettings (_)
Expand Down
63 changes: 63 additions & 0 deletions outputters/base.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
local outputter = pl.class()
outputter.type = "outputter"
outputter._name = "base"

function outputter._init () end

function outputter.newPage () end

function outputter.finish () end

function outputter.getCursor () end

function outputter.setCursor (_, _, _, _) end

function outputter.setColor () end

function outputter.pushColor () end

function outputter.popColor () end

function outputter.drawHbox (_, _, _) end

function outputter.setFont (_, _) end

function outputter.drawImage (_, _, _, _, _, _) end

function outputter.getImageSize (_, _) end

function outputter.drawSVG () end

function outputter.drawRule (_, _, _, _, _) end

function outputter.debugFrame (_, _, _) end

function outputter.debugHbox (_, _, _) end

function outputter.linkAnchor (_, _, _) end -- Unstable API

function outputter.enterLinkTarget (_, _, _, _, _) end -- Unstable API

function outputter.leaveLinkTarget (_, _, _, _, _, _, _) end -- Unstable API

function outputter.setMetadata (_, _, _) end

function outputter.setBookmark (_, _, _) end

function outputter:getOutputFilename ()
local fname
if SILE.outputFilename then
fname = SILE.outputFilename
elseif SILE.input.filenames[1] then
fname = pl.path.splitext(SILE.input.filenames[1])
if self.extension then
fname = fname .. "." .. self.extension
end
end
if not fname then
SU.error("Cannot guess output filename without an input name")
end
return fname
end

return outputter
Loading