Skip to content

Commit

Permalink
refactor(packages): Mode \pdf:literal to pdfstructure package
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jan 6, 2024
1 parent e3879a8 commit d5e728d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
24 changes: 2 additions & 22 deletions packages/pdf/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,8 @@ function package:registerCommands ()
})
end)

self:registerCommand("pdf:literal", function (_, content)
-- NOTE: This method is used by the pdfstructure package and should
-- probably be moved elsewhere, so there's no attempt here to delegate
-- the low-level libtexpdf call to te outputter.
if SILE.outputter._name ~= "libtexpdf" then
SU.error("pdf package requires libtexpdf backend")
end
local pdf = require("justenoughlibtexpdf")
if type(SILE.outputter._ensureInit) == "function" then
SILE.outputter:_ensureInit()
end
SILE.typesetter:pushHbox({
value = nil,
height = SILE.measurement(0),
width = SILE.measurement(0),
depth = SILE.measurement(0),
outputYourself = function (_, _, _)
pdf.add_content(content[1])
end
})
end)

-- TODO: Shim to pdfannotations package
-- self:registerCommand("pdf:literal", function (_, content)
self:registerCommand("pdf:link", function (options, content)
local dest = SU.required(options, "dest", "pdf:link")
local external = SU.boolean(options.external, false)
Expand Down
21 changes: 21 additions & 0 deletions packages/pdfstructure/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,27 @@ function package:registerCommands ()
stPointer = oldstPointer
end)

self:registerCommand("pdf:literal", function (_, content)
-- NOTE: This method is used by the pdfstructure package and should
-- probably be moved elsewhere, so there's no attempt here to delegate
-- the low-level libtexpdf call to te outputter.
if SILE.outputter._name ~= "libtexpdf" then
SU.error("pdf package requires libtexpdf backend")
end
if type(SILE.outputter._ensureInit) == "function" then
SILE.outputter:_ensureInit()
end
SILE.typesetter:pushHbox({
value = nil,
height = SILE.measurement(0),
width = SILE.measurement(0),
depth = SILE.measurement(0),
outputYourself = function (_, _, _)
pdf.add_content(content[1])
end
})
end)

end

package.documentation = [[
Expand Down

0 comments on commit d5e728d

Please sign in to comment.