Skip to content

Commit 192941b

Browse files
committed
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 cec8459 commit 192941b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

_extensions/multibib/multibib.lua

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,18 @@ local refs_div = pandoc.Div({}, pandoc.Attr('refs'))
4343
local refs_div_with_properties
4444

4545
--- Run citeproc on a pandoc document
46-
local citeproc
47-
if utils.citeproc then
48-
-- Built-in Lua function
49-
citeproc = utils.citeproc
50-
else
46+
--
47+
-- Falls back to the external `pandoc-citeproc` filter if the built-in
48+
-- citeproc processor is not available. Tries to silence all citeproc
49+
-- warnings, which isn't possible in some versions.
50+
local citeproc = utils.citeproc
51+
if pcall(require, 'pandoc.log') and citeproc then
52+
-- silence all warnings if possible
53+
local log = require 'pandoc.log'
54+
citeproc = function (...)
55+
return select(2, log.silence(utils.citeproc, ...))
56+
end
57+
elseif not citeproc then
5158
-- Use pandoc as a citeproc processor
5259
citeproc = function (doc)
5360
local opts = {'--from=json', '--to=json', '--citeproc', '--quiet'}
@@ -56,7 +63,7 @@ else
5663
end
5764

5865
--- Resolve citations in the document by combining all bibliographies
59-
-- before running pandoc-citeproc on the full document.
66+
-- before running citeproc on the full document.
6067
local function resolve_doc_citations (doc)
6168
-- combine all bibliographies
6269
local meta = doc.meta

0 commit comments

Comments
 (0)