Skip to content

Commit

Permalink
Merge pull request #26 from Omikhleia/avoid-extra-toc-rerun-warning
Browse files Browse the repository at this point in the history
fix: avoid extra ToC rerun warnings when the ToC hasn't changed
  • Loading branch information
Omikhleia authored Mar 25, 2023
2 parents 448a264 + 8a31594 commit ec36878
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/resilient/tableofcontents/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function package:registerCommands ()
SILE.call("info", {
category = "toc",
value = {
label = content,
label = SU.stripContentPos(content),
level = (options.level or 1),
number = options.number,
link = dest
Expand Down
29 changes: 29 additions & 0 deletions resilient/hacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,32 @@ SILE.typesetters.base.initline = function (self)
oldInitLine(self)
end
-- END HACK FOR PARINDENT HBOX ISSUE

-- BEGIN HACK TOC
-- See https://github.com/sile-typesetter/sile/issues/1732
if not SU.stripContentPos then
--- Strip position, line and column recursively from a content tree.
-- This can be used to remove position details where we do not want them,
-- e.g. in table of contents entries (referring to the original content,
-- regardless where it was exactly, for the purpose of checking whether
-- the table of contents changed.)
--
SU.stripContentPos = function (content)
if type(content) ~= "table" then
return content
end
local stripped = {}
for k, v in pairs(content) do
if type(v) == "table" then
v = SU.stripContentPos(v)
end
stripped[k] = v
end
if content.id or content.command then
stripped.pos, stripped.col, stripped.lno = nil, nil, nil
end
return stripped
end
end

-- END HACK TOC

0 comments on commit ec36878

Please sign in to comment.