Skip to content

Commit

Permalink
fix(packages): PDF links can now span multiple lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Jan 30, 2024
1 parent 6c40bfe commit cb00087
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions packages/pdf/init.lua
Expand Up @@ -54,32 +54,23 @@ function package:registerCommands ()
borderwidth = borderwidth,
borderoffset = borderoffset
}
local x0, y0
SILE.typesetter:pushHbox({
value = nil,
height = 0,
width = 0,
depth = 0,
outputYourself = function (_, typesetter, _)
x0 = typesetter.frame.state.cursorX:tonumber()
y0 = (SILE.documentState.paperSize[2] - typesetter.frame.state.cursorY):tonumber()

SILE.typesetter:liner("pdf:link", content,
function (box, typesetter, line)
local x0 = typesetter.frame.state.cursorX:tonumber()
local y0 = (SILE.documentState.paperSize[2] - typesetter.frame.state.cursorY):tonumber()
SILE.outputter:beginLink(dest, opts)
end
})
local hbox, hlist = SILE.typesetter:makeHbox(content) -- hack
SILE.typesetter:pushHbox(hbox)
SILE.typesetter:pushHbox({
value = nil,
height = 0,
width = 0,
depth = 0,
outputYourself = function (_, typesetter, _)

-- Build the content.
-- Cursor will be moved by the actual definitive size.
box:outputContent(typesetter, line)
local x1 = typesetter.frame.state.cursorX:tonumber()
local y1 = (SILE.documentState.paperSize[2] - typesetter.frame.state.cursorY + hbox.height):tonumber()
local y1 = (SILE.documentState.paperSize[2] - typesetter.frame.state.cursorY + box.height):tonumber()

SILE.outputter:endLink(dest, opts, x0, y0, x1, y1) -- Unstable API
end
})
SILE.typesetter:pushHlist(hlist)
)

end)

self:registerCommand("pdf:metadata", function (options, _)
Expand Down

0 comments on commit cb00087

Please sign in to comment.