From 4cbb8d8e93958a998a49e42d0b49f19014761030 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 11 Jul 2024 16:55:14 +0200 Subject: [PATCH] include-files: use pandoc's warn function if possible Fixes: #281 --- include-files/include-files.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include-files/include-files.lua b/include-files/include-files.lua index f9f208e9..2499968c 100644 --- a/include-files/include-files.lua +++ b/include-files/include-files.lua @@ -10,6 +10,11 @@ local List = require 'pandoc.List' local path = require 'pandoc.path' local system = require 'pandoc.system' +local warn = pcall(require, 'pandoc.log') + and (require 'pandoc.log').warn + or warn + or function (msg) io.stderr:write(msg .. '\n') end + --- Get include auto mode local include_auto = false function get_vars (meta) @@ -85,7 +90,7 @@ function transclude (cb) if line:sub(1,2) ~= '//' then local fh = io.open(line) if not fh then - io.stderr:write("Cannot open file " .. line .. " | Skipping includes\n") + warn("Cannot open file " .. line .. " | Skipping includes") else -- read file as the given format with global reader options local contents = pandoc.read(