obsidian-pandoc
obsidian-pandoc copied to clipboard
Support Pandoc citation syntax
Suggested by Mara & SkepticMystic on Discord #plugins
See https://pandoc.org/MANUAL.html#citations
We'll need to
a) add a setting to specify a database file
b) parse [@foo, p. 33] syntax into whatever Pandoc likes best
c) add a --citeproc option to the CLI commands
d) ...
This will be enormously helpful in conjunction with Zotero and the Obsidian citation plugin
This may be a fair bit of work. I'll tentatively mark it for the 0.2.0 release and push it back a week or two if needed (possibly after submission to the community plugins list).
Extra feedback from @ argentum:
it would be neat to have a setting to add the bibliography file there (or multiple)
I'll probably make the database setting a comma separated list then
For the LaTeX export this would be quite useful, since you can specify libraries (that can live on different places on your computer) with \bibliography{definitions,zotero}.
So in your example, there are two files definitions.bib and zotero.bib which could be in random places? (Or they could be CSL-JSON or something too I suppose.) I assume it doesn't matter where they're stored to the plugin, it won't need to read the files directly.
Does this mean you want that \bibliography{list,of,bib,files} line injected into the TeX output, and a \printbibliography line injected at the end? Perhaps Pandoc does this for me though, I'm not entirely sure.
I'll take a closer look at this after all the existing bugs are fixed - this looks slightly trickier than expected.
No rush! You can add it only if it's possible, this is a one-liner that I can add manually in LaTeX after export.
The main takeaway is that definitions.bib and zotero.bib are separate files, potentially located on different directories. For a bit of context, in my case one contains @string definitions for conferences/journals to help with the consistent formatting, and the other contains the actual citekeys. Zotero also lets you export multiple bib/CSL files, e.g. one per collection, so it might be that some people want to add more than one (or two) files.
I was pointed here from the Obsidian #academic Discord. Supporting Pandoc citations would be huge for me and many others!
Thank you again for this usefull plugin.
Citeproc filter
Nevertheless, as many said in the previous comments, It would be great if you could add --citeproc filter, so that we could use our notes with Zotero (via the plugin obsidian-Citation). For the time being, I have to convert my note that contains bibliographic references directly with pandoc in command lines.
Thanks a lot
Damien
Hi @damienbelveze, @cobblepot1, @argenos, Using citations in this plugin is now possible!
It's just a little fiddly at the moment. I've tested using BibTeX citations with the --citeproc filter on version 0.2.2 but it might work on earlier versions.
Here's a tutorial explaining the fiddly bits: https://github.com/OliverBalfour/obsidian-pandoc/wiki/Citations-(work-in-progress)
The main caveat is you can either get Pandoc markdown extensions like citations, or Obsidian markdown extensions/plugin features, but not both. I'll think of ways to work around this if it becomes a pain point.
If you have any suggestions for improving this process or the documentation, I'm open to ideas.
Hi @damienbelveze, @cobblepot1, @argenos, Using citations in this plugin is now possible!
It's just a little fiddly at the moment. I've tested using BibTeX citations with the
--citeprocfilter on version 0.2.2 but it might work on earlier versions.Here's a tutorial explaining the fiddly bits: https://github.com/OliverBalfour/obsidian-pandoc/wiki/Citations-(work-in-progress)
The main caveat is you can either get Pandoc markdown extensions like citations, or Obsidian markdown extensions/plugin features, but not both. I'll think of ways to work around this if it becomes a pain point.
If you have any suggestions for improving this process or the documentation, I'm open to ideas.
Thanks Oliver! Just to clarify, by 'get' do you mean we can only have either one of those markdown extensions enabled on Obsidian, or only one extension involved in the export operation, or something else? I'm a noob and struggling to get my head around what's going on. I'm coming from Zettlr where exporting to PDF or DOCX with citekeys generating full references is a one-click operation.
Your excellent plugin is working for me, BTW. Two questions for you about it. Firstly, how can I change the citation style? I have a customised .csl file ready to go, and which works on Zotero & Zettlr, but I can't find how to use this for Obsidian exports. In Zettlr there's a particular box for putting that CSL style in (see screenshot).
Secondly, I get an error when the doc I try to export via pandoc has an icon in it, like here in this screenshot.
If it's not possible so support these icons in exports, can this plugin learn to just ignore icons?
Hi @damienbelveze, @cobblepot1, @argenos, Using citations in this plugin is now possible!
It's just a little fiddly at the moment. I've tested using BibTeX citations with the
--citeprocfilter on version 0.2.2 but it might work on earlier versions.Here's a tutorial explaining the fiddly bits: https://github.com/OliverBalfour/obsidian-pandoc/wiki/Citations-(work-in-progress)
The main caveat is you can either get Pandoc markdown extensions like citations, or Obsidian markdown extensions/plugin features, but not both. I'll think of ways to work around this if it becomes a pain point.
If you have any suggestions for improving this process or the documentation, I'm open to ideas.
Thank you Oliver,
I have the same question than @Kenanmike I tried to replicate
Hi @damienbelveze, @cobblepot1, @argenos, Using citations in this plugin is now possible!
It's just a little fiddly at the moment. I've tested using BibTeX citations with the
--citeprocfilter on version 0.2.2 but it might work on earlier versions.Here's a tutorial explaining the fiddly bits: https://github.com/OliverBalfour/obsidian-pandoc/wiki/Citations-(work-in-progress)
The main caveat is you can either get Pandoc markdown extensions like citations, or Obsidian markdown extensions/plugin features, but not both. I'll think of ways to work around this if it becomes a pain point.
If you have any suggestions for improving this process or the documentation, I'm open to ideas.
Thank you Oliver for this new release,
Once I have downloaded it this morning and loaded it into my Obsidian list of plugins, I tried to replicate the example you gave. I put your test.bib file in the same directory as my note (which I made it contain the same YAML frontmatter except for the path : bibliography: test.bib Then I put the same path in pandoc plugin argument (--metadata bibliography=test.bib --citeproc) To be sure the plugin Citations would not interfere, I unabled it (cf. @kenanmike 's question). But I have no result, just : "file test.bib not found in resource path". The answer to this issue is may be obvious to anybody else, but for the time being I cannot see it. Could you tell me what went wrong?
Thank you in advance,
@kenanmike
Thanks Oliver! Just to clarify, by 'get' do you mean we can only have either one of those markdown extensions enabled on Obsidian, or only one extension involved in the export operation, or something else? I'm a noob and struggling to get my head around what's going on. I'm coming from Zettlr where exporting to PDF or DOCX with citekeys generating full references is a one-click operation.
You can either have all of the Obsidian markdown features or all of the Pandoc markdown features, but not both. This is because a different method processes each type of markdown and there's no easy way to combine them. The (poorly named) Export files from HTML or markdown? setting determines which type of markdown to use - HTML means Obsidian, markdown means Pandoc. If you want a one-click hassle-free export with references, this plugin will get you most of the way there. However, using Zettlr alongside Obsidian when you need to export files is what I'd recommend if you're used to it and find it any easier.
@kenanmike
Your excellent plugin is working for me, BTW. Two questions for you about it. Firstly, how can I change the citation style? I have a customised .csl file ready to go, and which works on Zotero & Zettlr, but I can't find how to use this for Obsidian exports. In Zettlr there's a particular box for putting that CSL style in (see screenshot).
Glad to hear it works! For the citation style, that's where the fiddly-ness comes into play. You'll need to set the citation style using a Pandoc argument by adding the right command line flag to Extra Pandoc arguments. I think this means adding --csl=/path/to/file.csl to a new line in the extra arguments, but I haven't tested this
Secondly, I get an error when the doc I try to export via pandoc has an icon in it, like here in this screenshot.
Sorry about this, it doesn't handle Unicode in PDF exports very well because LaTeX and emoji are not friends... This relates to #22, I'll fix this separately. (The fix might just be to display a more helpful error message if LaTeX cannot be made to support Unicode cleanly)
@damienbelveze
Yes, the file path searching isn't the same as using the terminal and I'm not sure why. That would explain why it can't find your test.bib file. To fix this, you'll just need to provide the full path, eg --metadata bibliography=/path/to/test.bib --citeproc.
By the way, does the citations plugin interfere with this plugin at all?