Closed amine-aboufirass closed 1 year ago
You don't need a filter for this. Call pandoc with --biblatex
or --natbib
.
I'm not really a fan of the default implementation and would like to make my own. Part of pandoc's power is that it allows for extending/replacing functionality with one's own readers/writers/filters.
Interesting. Can you say more about the perceived shortcomings of the default implementation?
@tarleb I don't think it has shortcomings, I just like the freedom of being able to build my own converters...
The problem with your code is from return pf.Citation(text)
. If you want to cook your own LaTeX, you shouldn't be returning a Citation
. Try using raw LaTeX block for example.
Another problem is pandoc -F write.py --template template.latex -t plain -o test.tex test.md
, it should be -t latex
instead.
It is ok to make your own converters, but frankly citeproc and its friends are high usage tools where it is certainly not perfect, but has been battle tested. It would be easier to first study what that tool has to offer first (the pandoc manual has documented this, but it is dense, so make sure you understand all aspects of it.) Then raising questions or pointing out limitations about it would be beneficial even if you want to roll your own. You can start with pandoc-discuss for that purpose.
I have the following files in the folder
root
:The contents of
template.latex
are as follows:The contents of
test.md
are as follows:The contents of
write.py
are as follows:As you can see I am trying to convert the individual citations in Markdown to LaTeX style citations. For instance
@online-resource
would be converted to\cite{online-resource}
. So my expected result is as followsWhen I run
pandoc -F write.py --template template.latex -t plain -o test.tex test.md
I get the following in
test.tex
So the citations are not converted as I expect, and I'm not sure why. I tried various combinations of returning the text in different API objects such as
pf.Str(text)
,pf.Inline(text)
orpf.Citation(pf.Str(text))
but none of those combinations work.Any help or pointers would be greatly appreciated.