jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.36k stars 244 forks source link

strip braces when copying formatted citation? #582

Closed ssfrr closed 6 years ago

ssfrr commented 6 years ago

If I have a BibTeX entry like:

@inproceedings{ozerov_multichannel_2011,
  title = {Multichannel Nonnegative Tensor Factorization with Structured Constraints for User-Guided Audio Source Separation},
  booktitle = {Acoustics, {{Speech}} and {{Signal Processing}} ({{ICASSP}}), 2011 {{IEEE International Conference}} On},
  publisher = {{IEEE}},
  author = {Ozerov, Alexey and Févotte, Cédric and Blouet, Raphaël and Durrieu, Jean-Louis},
  year = {2011},
  pages = {257--260},
  file = {C:\\Users\\sfr\\Zotero\\storage\\823TITL6\\Ozerov et al. - 2011 - Multichannel nonnegative tensor factorization with.pdf;C:\\Users\\sfr\\Zotero\\storage\\XQQZCJEG\\5946389.html}
}

that was exported from Zotero, and I use the "Copy Formatted Citation to Clipboard" option on a citation, I get a string like:

Ozerov, A., Févotte, C., Blouet, R., & Durrieu, J., Multichannel nonnegative tensor
factorization with structured constraints for user-guided audio source separation,
In , Acoustics, {{Speech}} and {{Signal Processing}} ({{ICASSP}}), 2011 {{IEEE International
Conference}} On (pp. 257–260) (2011). : IEEE.

(ignoring some of the other weird formatting things that are maybe due to me not having the right fields populated...) Is there any way to have org-ref strip off the {{}} braces?

jkitchin commented 6 years ago

The fastest way is probably to either advise org-ref-format-entry, or just replace it with what you want. e.g.

#+BEGIN_SRC emacs-lisp
(defun org-ref-format-entry (key)
  "Returns a formatted bibtex entry for KEY."
  (let* ((bibtex-completion-bibliography (org-ref-find-bibliography))
     (s (org-ref-format-bibtex-entry (ignore-errors (bibtex-completion-get-entry key)))))
    (replace-regexp-in-string "{\\|}" "" s)))
#+END_SRC

I don't see any hooks that would make this easier to do.

ssfrr commented 6 years ago

That code snippet seems to be doing exactly what I want. thanks!