From 582eb05d76f967bfc678c742df4bcd35211185fb Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 7 Dec 2023 23:57:21 +0300 Subject: [PATCH] fix: Handle documents on STDIN and/or in Lua 5.1 --- packages/resilient/styles/init.lua | 6 ++++-- packages/resilient/tableofcontents/init.lua | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/resilient/styles/init.lua b/packages/resilient/styles/init.lua index 2a2e687..4c84d68 100644 --- a/packages/resilient/styles/init.lua +++ b/packages/resilient/styles/init.lua @@ -88,7 +88,8 @@ end function package:readStyles () local yaml = require("resilient-tinyyaml") - local fname = SILE.masterFilename .. '-styles.yml' + local basename = pl.path.splitext(SILE.input.filenames[1]) + local fname = basename .. '-styles.yml' local styfile, _ = io.open(fname) if not styfile then SILE.scratch.styles.loaded = {} @@ -136,7 +137,8 @@ function package.writeStyles () -- NOTE: Not called as a package method (invoked end local stydata = tableToYaml(SILE.scratch.styles.specs) - local fname = SILE.masterFilename .. '-styles.yml' + local basename = pl.path.splitext(SILE.input.filenames[1]) + local fname = basename .. '-styles.yml' SU.debug("resilient.styles", "Writing style file", fname, ":", count, "new style(s)") local styfile, err = io.open(fname, "w") if not styfile then return SU.error(err) end diff --git a/packages/resilient/tableofcontents/init.lua b/packages/resilient/tableofcontents/init.lua index 6dba8e3..0d029a3 100644 --- a/packages/resilient/tableofcontents/init.lua +++ b/packages/resilient/tableofcontents/init.lua @@ -100,7 +100,8 @@ end function package.writeToc (_) local tocdata = pl.pretty.write(SILE.scratch.tableofcontents) - local tocfile, err = io.open(SILE.masterFilename .. '.toc', "w") + local basename = pl.path.splitext(SILE.input.filenames[1]) + local tocfile, err = io.open(basename .. '.toc', "w") if not tocfile then return SU.error(err) end tocfile:write("return " .. tocdata) tocfile:close() @@ -115,7 +116,8 @@ function package.readToc (_) -- already loaded return SILE.scratch._tableofcontents end - local tocfile, _ = io.open(SILE.masterFilename .. '.toc') + local basename = pl.path.splitext(pl.path.normpath(SILE.input.filenames[1])) + local tocfile, _ = io.open(basename .. '.toc') if not tocfile then return false -- No TOC yet end