Skip to content

Commit 7574925

Browse files
tarlebwlupton
authored andcommitted
Silence all citeproc warnings if possible
This requires the `pandoc.log` Lua module, which first became available in pandoc 3.2. Fixes: #13
1 parent 91e8931 commit 7574925

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

_extensions/multibib/multibib.lua

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,21 @@ local refs_div_with_properties
5454
local supports_quiet_arg = false
5555

5656
--- Run citeproc on a pandoc document
57-
local function citeproc(doc, quiet)
58-
-- utils.citeproc() was added in 2.19.1
59-
if utils.citeproc and supports_quiet_arg then
60-
-- Built-in Lua function
61-
return utils.citeproc(doc, quiet)
62-
else
63-
-- Use pandoc as a citeproc processor
64-
local path = PANDOC_STATE.resource_path
65-
local opts = {'--from=json', '--to=json', '--citeproc',
66-
'--resource-path=' .. table.concat(path, ':'),
67-
quiet and '--quiet' or nil}
57+
--
58+
-- Falls back to the external `pandoc-citeproc` filter if the built-in
59+
-- citeproc processor is not available. Tries to silence all citeproc
60+
-- warnings, which isn't possible in some versions.
61+
local citeproc = utils.citeproc
62+
if pcall(require, 'pandoc.log') and citeproc then
63+
-- silence all warnings if possible
64+
local log = require 'pandoc.log'
65+
citeproc = function (...)
66+
return select(2, log.silence(utils.citeproc, ...))
67+
end
68+
elseif not citeproc then
69+
-- Use pandoc as a citeproc processor
70+
citeproc = function (doc)
71+
local opts = {'--from=json', '--to=json', '--citeproc', '--quiet'}
6872
return run_json_filter(doc, 'pandoc', opts)
6973
end
7074
end

0 commit comments

Comments
 (0)