Skip to content

Commit 51a990d

Browse files
lmunchtarleb
authored andcommitted
Use relative path for images
Use the recursive nature of the filter to build up the correct relative path to images
1 parent d7c791d commit 51a990d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

include-files/include-files.lua

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function update_last_level(header)
2525
end
2626

2727
--- Update contents of included file
28-
local function update_contents(blocks, shift_by)
28+
local function update_contents(blocks, shift_by, include_path)
2929
local update_contents_filter = {
3030
-- Shift headings in block list by given number
3131
Header = function (header)
@@ -37,7 +37,7 @@ local function update_contents(blocks, shift_by)
3737
-- If image paths are relative then prepend include file path
3838
Image = function (image)
3939
if path.is_relative(image.src) then
40-
image.src = path.join({system.get_working_directory(), image.src})
40+
image.src = path.normalize(path.join({include_path, image.src}))
4141
end
4242
return image
4343
end
@@ -92,12 +92,8 @@ function transclude (cb)
9292
end).content
9393
--- reset to level before recursion
9494
last_heading_level = buffer_last_heading_level
95-
blocks:extend(
96-
system.with_working_directory(
97-
path.directory(line),
98-
function ()
99-
return update_contents(contents, shift_heading_level_by)
100-
end))
95+
blocks:extend(update_contents(contents, shift_heading_level_by,
96+
path.directory(line)))
10197
fh:close()
10298
end
10399
end

0 commit comments

Comments
 (0)