From af1d1e8a8edc7b4dff4352a564d28ffa557de688 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 23 Oct 2024 16:37:49 +0300 Subject: [PATCH 1/2] chore(core): Add chunk names to side-loaded code --- inputters/lua.lua | 2 +- packages/tableofcontents/init.lua | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/inputters/lua.lua b/inputters/lua.lua index cc6713597..4e5bfa165 100644 --- a/inputters/lua.lua +++ b/inputters/lua.lua @@ -19,7 +19,7 @@ function inputter.appropriate (round, filename, doc) end function inputter.parse (_, doc) - local result, err = load(doc) + local result, err = load(doc, SILE.currentlyProcessingFile) if not result then SU.error(err) end diff --git a/packages/tableofcontents/init.lua b/packages/tableofcontents/init.lua index 7a6c0b835..73606ca3e 100644 --- a/packages/tableofcontents/init.lua +++ b/packages/tableofcontents/init.lua @@ -38,12 +38,13 @@ function package.readToc (_) -- already loaded return SILE.scratch._tableofcontents end - local tocfile, _ = io.open(pl.path.splitext(SILE.input.filenames[1]) .. ".toc") + local tocfile_name = (pl.path.splitext(SILE.input.filenames[1]) .. ".toc") + local tocfile, _ = io.open(tocfile_name) if not tocfile then return false -- No TOC yet end local doc = tocfile:read("*all") - local toc = assert(load(doc))() + local toc = assert(load(doc), tocfile_name)() SILE.scratch._tableofcontents = toc return SILE.scratch._tableofcontents end From f69fb616161e14b5a2b51d4735954f40de3feeec Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 23 Oct 2024 16:38:36 +0300 Subject: [PATCH 2/2] chore(core): Limit side-loaded content to text only when not expecting binary --- packages/tableofcontents/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tableofcontents/init.lua b/packages/tableofcontents/init.lua index 73606ca3e..248ce9d6c 100644 --- a/packages/tableofcontents/init.lua +++ b/packages/tableofcontents/init.lua @@ -44,7 +44,7 @@ function package.readToc (_) return false -- No TOC yet end local doc = tocfile:read("*all") - local toc = assert(load(doc), tocfile_name)() + local toc = assert(load(doc), tocfile_name, "r")() SILE.scratch._tableofcontents = toc return SILE.scratch._tableofcontents end