@@ -54,17 +54,21 @@ local refs_div_with_properties
5454local 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
7074end
0 commit comments