Skip to content

Commit

Permalink
fix(packages): Do not issue a warning when tableofcontent isn't used
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Jan 15, 2025
1 parent 3d72535 commit 9c9c5eb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/resilient/tableofcontents/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ local tocNumberStyles = {
{},
{},
}

local _toc_used = false

function package:_init (options)
base._init(self, options)
SILE.scratch.tableofcontents = SILE.scratch.tableofcontents or {}
Expand Down Expand Up @@ -105,7 +108,7 @@ function package.writeToc (_)
tocfile:write("return " .. tocdata)
tocfile:close()

if not pl.tablex.deepcompare(SILE.scratch.tableofcontents, SILE.scratch._tableofcontents) then
if _toc_used and not pl.tablex.deepcompare(SILE.scratch.tableofcontents, SILE.scratch._tableofcontents) then
io.stderr:write("\n! Warning: table of contents has changed, please rerun SILE to update it.")
end
end
Expand All @@ -127,7 +130,7 @@ end

function package:registerCommands ()

-- Warning for users of the legacy tableofcontents
-- Warning for users of the legacy (SILE core) tableofcontents
self:registerCommand("tableofcontents:title", function (_, _)
SU.error("The resilient.tableofcontents package does not use the tableofcontents:title command.")
end)
Expand All @@ -148,6 +151,8 @@ function package:registerCommands ()
return
end

_toc_used = true

-- Temporarilly kill footnotes and labels (fragile)
local oldFt = SILE.Commands["footnote"]
SILE.Commands["footnote"] = function () end
Expand Down

0 comments on commit 9c9c5eb

Please sign in to comment.