Skip to content

Commit

Permalink
fix(packages): Don't warn on TOC content change if not actually used
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Sep 4, 2023
1 parent 18526ce commit 87c443d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/tableofcontents/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if not SILE.scratch._tableofcontents then
SILE.scratch._tableofcontents = {}
end

local toc_used = false

function package:moveTocNodes ()
local node = SILE.scratch.info.thispage.toc
if node then
Expand All @@ -24,8 +26,8 @@ function package.writeToc (_)
tocfile:write("return " .. tocdata)
tocfile:close()

if 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.")
if toc_used and not pl.tablex.deepcompare(SILE.scratch.tableofcontents, SILE.scratch._tableofcontents) then
SU.msg("Notice: the table of contents has changed, please rerun SILE to update it.")
end
end

Expand Down Expand Up @@ -115,6 +117,7 @@ function package:registerCommands ()
self:registerCommand("tableofcontents", function (options, _)
local depth = SU.cast("integer", options.depth or 3)
local linking = SU.boolean(options.linking, true)
local toc_used = true
local toc = self:readToc()
if toc == false then
SILE.call("tableofcontents:notocmessage")
Expand Down

0 comments on commit 87c443d

Please sign in to comment.