Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Zotero "live references" allowed by Better Bibtex. #20

Open
EmmanuelCharpentier opened this issue Aug 11, 2022 · 8 comments
Open

Comments

@EmmanuelCharpentier
Copy link

The Better Bibtex plugin to the Zotero reference manager allows the export of reference as "live" citationss, which can be used and (mostly) exported from Markdown to odt/docx, the resulting docuent having "live" reference editable on LibreOffice/Word via their respective Zotero plugins.

Can such a functionality be implemented to allow the same exportation from Org ?

This almost certainly involves some additions to Org itself...

@a-fent
Copy link
Collaborator

a-fent commented Aug 12, 2022

Short term - direct use of pandoc

I think you can already do this already just by calling pandoc directly on an org document with citations in org's format.

pandoc -s --lua-filter=./zotero.lua --metadata=zotero_scannable_cite:false --metadata=zotero_cite-method:csl --metadata=zotero_csl_style:vancouver-brackets -o test_citations_converted.odt test_citations.org

A couple of notes:

  • Doesn't seem to work if scannable_cite is true
  • The csl style must be specified
  • Code execution in SRC blocks won't happen (unlike with ox-pandoc)
  • The metadata and filter information can't be passed in Org headers (unlike with ox-pandoc)

Longer term - Org / ox-pandoc integration

To make this integrate with ox-pandoc, we'd need an Org citation exporter that just reproduces the org citation syntax rather than trying to resolve it. Maybe oc-identity. These aren't very complex to write (see e.g. oc-biblatex.el in the Org distribution) but I'd need to do some research.

It isn't as easy as handling some other "identity" items in ox-pandoc (for example _LATEX and _HTML blocks) because citation processing is handled outside the normal export element processing in Org.

@bdarcus I wonder if oc-identity export processor could be proposed to Org? It could be added for the time being as proof of concept to ox-pandoc, for people who want to use pandoc to handle their citations.

@a-fent
Copy link
Collaborator

a-fent commented Aug 12, 2022

Something to try with ox-pandoc - does this work for you? Evaluate

(defun org-cite-identity-export-bibliography (_keys _files _style props &rest _)
  "#+print_bibliography:"
  )

(defun org-cite-identity-export-citation (citation style _ info)
  (org-element-interpret-data citation)
  )

;;; Register `identity' processor
(org-cite-register-processor 'identity
  :export-bibliography #'org-cite-identity-export-bibliography
  :export-citation #'org-cite-identity-export-citation
  )

(provide 'oc-identity)

And then add to the header of the file you offered here: #1 (comment) the line #+CITE_EXPORT: identity

Then try org-pandoc-export-to-odt. After refreshing, the exported ODT has "live" references.

@bdarcus
Copy link

bdarcus commented Aug 12, 2022

I wonder if oc-identity export processor could be proposed to Org? It could be added for the time being as proof of concept to ox-pandoc, for people who want to use pandoc to handle their citations.

That could indeed be a good idea.

I had earlier also wondered how feasible it would be to modify oc-csl to allow configurable backends, but your idea is probably better.

EDIT: I guess one downside would be that the conversion more generally may not be as feature-complete as org itself?

The POC would indeed be a good test.

There is an interesting strategic question for org going forward about what processors to include, and what to keep separate. (To be clear, I'm not sure myself)

It could be, for example, that if you like the result, you split it off as a separate package, that works well whether or not it's in org itself?

@yantar92
Copy link
Member

yantar92 commented Aug 12, 2022 via email

@a-fent
Copy link
Collaborator

a-fent commented Aug 12, 2022

What about simply adding (pandoc . nil) to org-cite-export-processors?

Thanks for the suggestion Ihor. I am probably being dim but however I try to do variants on (add-to-list 'org-cite-export-processors '(pandoc . nil)) I get the error "Invalid cite export definition: nil". Nil-ing the whole variable just means citations are ignore i.e. deleted in export, which the variable definition hints at.

Also there is no way (apart from binding variables) to set #+cite_export: nil at file-level at the moment, right?

@yantar92
Copy link
Member

yantar92 commented Aug 13, 2022 via email

@a-fent
Copy link
Collaborator

a-fent commented Aug 13, 2022

Hmm. You are right. I missed that promise and thought (wrongly) that missing citations are a result of absence of the relevant transcoders.

Thank you for checking this.

#+BIBLIOGRAPHY: bib.bib 
#+CITE_EXPORT: 
This is test ***@***.***.

Ah OK, didn't know you could do that. It does something a bit different to the oc-identity I suggested to the OP - it removes all citations and bibliography calls in the output.

oc-identity preserves the original Org cite syntax so it can be processed by something else that understands it (e.g. pandoc).

@yantar92
Copy link
Member

yantar92 commented Aug 14, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants