Skip to content

Commit 36b55fc

Browse files
cscheidcderv
authored andcommitted
sometimes projectDirectory can still be nil
1 parent 21c7f4d commit 36b55fc

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎src/resources/pandoc/datadir/init.lua‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,16 +645,27 @@ local function inputFile()
645645
return source
646646
else
647647
local projectDir = projectDirectory()
648-
-- we now always have a projectDir, even in single-file settings
649-
assert(projectDir)
650-
return pandoc.path.join({projectDir, source})
648+
if projectDir then
649+
return pandoc.path.join({projectDir, source})
650+
else
651+
-- outside of a project, quarto already changes
652+
-- pwd to the file's directory prior to calling pandoc,
653+
-- so we should just use the filename
654+
-- https://github.com/quarto-dev/quarto-cli/issues/7424
655+
local path_parts = pandoc.path.split(source)
656+
return pandoc.path.join({pandoc.system.get_working_directory(), path_parts[#path_parts]})
657+
end
651658
end
652659
end
653660

654661
local function outputFile()
655662
local projectOutDir = projectOutputDirectory()
656663
if projectOutDir then
657664
local projectDir = projectDirectory()
665+
print("---")
666+
print(projectDir)
667+
print(pandoc.path.directory(inputFile()))
668+
print("---")
658669
if projectDir then
659670
local input = pandoc.path.directory(inputFile())
660671
local relativeDir = pandoc.path.make_relative(input, projectDir)

0 commit comments

Comments
 (0)