diff --git a/classes/base.lua b/classes/base.lua index e91b2feec..7cd902029 100644 --- a/classes/base.lua +++ b/classes/base.lua @@ -575,9 +575,9 @@ function class:finish () end SILE.typesetter:runHooks("pageend") -- normally run by the typesetter self:endPage() - if SILE.typesetter then - assert(SILE.typesetter:isQueueEmpty(), "queues not empty") - end + if SILE.typesetter then + assert(SILE.typesetter:isQueueEmpty(), "queues not empty") + end SILE.outputter:finish() self:runHooks("finish") end diff --git a/core/makedeps.lua b/core/makedeps.lua index 41718b6da..5e194821c 100644 --- a/core/makedeps.lua +++ b/core/makedeps.lua @@ -25,7 +25,7 @@ local makeDeps = { write = function (self) self:add_modules() if type(self.filename) ~= "string" then - self.filename = SILE.masterFilename .. ".d" + self.filename = pl.path.splitext(SILE.input.filenames[1]) .. ".d" end local depfile, err = io.open(self.filename, "w") if not depfile then return SU.error(err) end diff --git a/core/sile.lua b/core/sile.lua index eb9471610..377f73c14 100644 --- a/core/sile.lua +++ b/core/sile.lua @@ -291,7 +291,7 @@ function SILE.processString (doc, format, filename, options) -- a specific inputter to use, use it at the exclusion of all content type -- detection local inputter - if filename and pl.path.splitext(pl.path.normcase(filename)) == SILE.masterFilename and SILE.inputter then + if filename and pl.path.normcase(pl.path.normpath(filename)) == pl.path.normcase(SILE.input.filenames[1]) and SILE.inputter then inputter = SILE.inputter else format = format or detectFormat(doc, filename) @@ -301,7 +301,7 @@ function SILE.processString (doc, format, filename, options) inputter = SILE.inputters[format](options) -- If we did content detection *and* this is the master file, save the -- inputter for posterity and postambles - if filename and pl.path.splitext(pl.path.normcase(filename)) == SILE.masterFilename then + if filename and pl.path.normcase(filename) == pl.path.normcase(SILE.input.filenames[1]) then SILE.inputter = inputter end end @@ -315,17 +315,15 @@ function SILE.processFile (filename, format, options) local doc if filename == "-" then filename = "STDIN" - SILE.masterFilename = "STDIN" doc = io.stdin:read("*a") else -- Turn slashes around in the event we get passed a path from a Windows shell filename = filename:gsub("\\", "/") if not SILE.masterFilename then - -- Strip extension - SILE.masterFilename = string.match(filename, "(.+)%..-$") or filename + SILE.masterFilename = pl.path.splitext(pl.path.normpath(filename)) end - if SILE.masterFilename and not SILE.masterDir then - SILE.masterDir = SILE.masterFilename:match("(.-)[^%/]+$") + if SILE.input.filenames[1] and not SILE.masterDir then + SILE.masterDir = pl.path.dirname(SILE.input.filenames[1]) end if SILE.masterDir and SILE.masterDir:len() >= 1 then _G.extendSilePath(SILE.masterDir) @@ -463,7 +461,7 @@ function SILE.finish () end if SU.debugging("profile") then ProFi:stop() - ProFi:writeReport(SILE.masterFilename..'.profile.txt') + ProFi:writeReport(pl.path.splitext(SILE.input.filenames[1]) .. '.profile.txt') end if SU.debugging("versions") then SILE.shaper:debugVersions() diff --git a/documentation/c10-classdesign.sil b/documentation/c10-classdesign.sil index 6038fdf11..e658d0327 100644 --- a/documentation/c10-classdesign.sil +++ b/documentation/c10-classdesign.sil @@ -496,7 +496,7 @@ Here is a function to be called by the \code{finish} output routine: function package.writeToc (_) -- (Simplified from the actual implementation.) local tocdata = pl.pretty.write(SILE.scratch.tableofcontents) - local tocfile, err = io.open(SILE.masterFilename .. '.toc', "w") + local tocfile, err = io.open(pl.path.splitext(SILE.input.filenames[1]) .. '.toc', "w") if not tocfile then return SU.error(err) end tocfile:write("return " .. tocdata) tocfile:close() diff --git a/outputters/base.lua b/outputters/base.lua index b130f4b10..a5ce0aacd 100644 --- a/outputters/base.lua +++ b/outputters/base.lua @@ -38,8 +38,8 @@ function outputter:getOutputFilename () local fname if SILE.outputFilename then fname = SILE.outputFilename - elseif SILE.masterFilename then - fname = SILE.masterFilename + elseif SILE.input.filenames[1] then + fname = pl.path.splitext(SILE.input.filenames[1]) if self.extension then fname = fname .. "." .. self.extension end diff --git a/packages/cropmarks/init.lua b/packages/cropmarks/init.lua index f206a310d..59b6b8f71 100644 --- a/packages/cropmarks/init.lua +++ b/packages/cropmarks/init.lua @@ -64,7 +64,7 @@ end function package:registerCommands () self:registerCommand("crop:header", function (_, _) - local info = SILE.masterFilename .. " - " .. self.class:date("%x %X") .. " - " .. outcounter + local info = SILE.input.filenames[1] .. " - " .. self.class:date("%x %X") .. " - " .. outcounter SILE.typesetter:typeset(info) end) diff --git a/packages/tableofcontents/init.lua b/packages/tableofcontents/init.lua index 0fb8bd667..9c74ef9d6 100644 --- a/packages/tableofcontents/init.lua +++ b/packages/tableofcontents/init.lua @@ -19,7 +19,7 @@ end function package.writeToc (_) local tocdata = pl.pretty.write(SILE.scratch.tableofcontents) - local tocfile, err = io.open(SILE.masterFilename .. '.toc', "w") + local tocfile, err = io.open(pl.path.splitext(SILE.input.filenames[1]) .. '.toc', "w") if not tocfile then return SU.error(err) end tocfile:write("return " .. tocdata) tocfile:close() @@ -34,7 +34,7 @@ function package.readToc (_) -- already loaded return SILE.scratch._tableofcontents end - local tocfile, _ = io.open(SILE.masterFilename .. '.toc') + local tocfile, _ = io.open(pl.path.splitext(SILE.input.filenames[1]) .. '.toc') if not tocfile then return false -- No TOC yet end