-- After +rebase_relative_paths, Pandoc resolves media to absolute paths.
-- Typst projects expose book-root assets as root-relative paths instead.
local root = os.getenv("BOOK_DIR")

function Image(image)
  if root and image.src:sub(1, #root + 1) == root .. "/" then
    image.src = "/" .. image.src:sub(#root + 2)
  end
  return image
end
