Skip to content

Commit

Permalink
fix(core): Make masterFilename actually a filename
Browse files Browse the repository at this point in the history
Process the basename when that's specifically what we need rather than
making it a basename initially and not having the extension information
when we need it.
  • Loading branch information
alerque committed Jul 12, 2023
1 parent 83d1423 commit 759131e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions classes/base.lua
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/makedeps.lua
Expand Up @@ -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.masterFilename) .. ".d"
end
local depfile, err = io.open(self.filename, "w")
if not depfile then return SU.error(err) end
Expand Down
11 changes: 5 additions & 6 deletions core/sile.lua
Expand Up @@ -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.masterFilename) and SILE.inputter then
inputter = SILE.inputter
else
format = format or detectFormat(doc, filename)
Expand All @@ -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) == SILE.masterFilename then
SILE.inputter = inputter
end
end
Expand All @@ -321,11 +321,10 @@ function SILE.processFile (filename, format, options)
-- 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.normpath(filename)
end
if SILE.masterFilename and not SILE.masterDir then
SILE.masterDir = SILE.masterFilename:match("(.-)[^%/]+$")
SILE.masterDir = pl.path.dirname(SILE.masterFilename)
end
if SILE.masterDir and SILE.masterDir:len() >= 1 then
_G.extendSilePath(SILE.masterDir)
Expand Down Expand Up @@ -463,7 +462,7 @@ function SILE.finish ()
end
if SU.debugging("profile") then
ProFi:stop()
ProFi:writeReport(SILE.masterFilename..'.profile.txt')
ProFi:writeReport(pl.path.splitext(SILE.masterFilename) .. '.profile.txt')
end
if SU.debugging("versions") then
SILE.shaper:debugVersions()
Expand Down
2 changes: 1 addition & 1 deletion documentation/c10-classdesign.sil
Expand Up @@ -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.masterFilename) .. '.toc', "w")
if not tocfile then return SU.error(err) end
tocfile:write("return " .. tocdata)
tocfile:close()
Expand Down
2 changes: 1 addition & 1 deletion outputters/base.lua
Expand Up @@ -39,7 +39,7 @@ function outputter:getOutputFilename ()
if SILE.outputFilename then
fname = SILE.outputFilename
elseif SILE.masterFilename then
fname = SILE.masterFilename
fname = pl.path.splitext(SILE.masterFilename)
if self.extension then
fname = fname .. "." .. self.extension
end
Expand Down
4 changes: 2 additions & 2 deletions packages/tableofcontents/init.lua
Expand Up @@ -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.masterFilename) .. '.toc', "w")
if not tocfile then return SU.error(err) end
tocfile:write("return " .. tocdata)
tocfile:close()
Expand All @@ -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.masterFilename) .. '.toc')
if not tocfile then
return false -- No TOC yet
end
Expand Down

0 comments on commit 759131e

Please sign in to comment.