Open tobiasBora opened 3 years ago
@tarleb can probably give a better answer. But try with --citeproc --bibliography ref.bib
. It could be that the issue is just that we're not parsing bibliography:...
as metadata.
Thanks for your answer. I can confirm that --bibliography ref.bib
helps for the pdf output. Would it be possible to let pandoc
recognize the bibliography:ref
syntax and the bibliographystyle:...
syntax? Indeed I'd like to run pandoc on lots of files at the same time (for a website), and each file may have a different bibliography file.
Also, is it normal if the bibliography export fails in html? It would be great to have a way to have citations in html files. The command used is:
pandoc -t html test.org -s --from=org-citations --bibliography ref.bib -o test_pandoc.html --mathjax
(I need to remove the --citeproc
as it tells me that it's not supported)
I agree that it would make sense to parse these lines if the citations
extension is enabled.
Note that, in order to enable an extension, it must be preceded by a plus +
: --from=org+citations
. However, citations
is enabled by default for org, so the option can be omitted.
You can use a Lua filter as a temporary workaround. The following will add the bibliography metadata value as intended, but ignore the bibliographystyle
. It seems better to choose a CSL style explicitly.
local bibliography = pandoc.List()
local function is_linebreak(item)
return not item or item.t == 'SoftBreak'
end
function Para (p)
for i, inln in ipairs(p.content) do
local str = pandoc.utils.stringify(inln)
if is_linebreak(p.content[i-1]) and is_linebreak(p.content[i+1]) then
local bib = str:match 'bibliography:(.+)'
if bib then
bibliography:insert(bib)
-- remove paragraph
return {}
end
end
end
end
function Meta (meta)
meta.bibliography = bibliography
return meta
end
Great, thanks a lot (filters are amazing...)! Can confirm that it works for both html/latex output:
$ pandoc test.org -L filter_bib.lua -s -t latex --natbib
$ pandoc test.org -L filter_org.lua -L filter_bib.lua -s -t html --citeproc
It would be great if bibliography
and bibliographystyle
could be recognized by pandoc automatically!
Hello,
According to the documentation, citations in org-ref style should work in
.org
files, however I can't make them work with Pandoc.Step to reproduce:
test.org
:ref.bib
:Compilation command (to pdf and html):
I also tried adding
--from=org-citations
, same issue.Pandoc version: Tried with
2.7.3
and