-
Notifications
You must be signed in to change notification settings - Fork 74
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
allow for more formats (other than APA) when converting entries to strings #235
Comments
I'd be happy to include this capability but will probably not be able to work on this myself. If someone wants to give it a shot (should be easy actually) and prepare a PR, I'd be happy to provide guidance. |
If you use org-ref, you can customise |
Ah, I overlooked the second point. True, the current formatting code is not very flexible. However, the APA specification is ridiculously complex and it's actually not trivial to fully cover it. Easy improvements are certainly possible, though. |
I just wanted to let you know that I'm playing around with a more general approach that can process something like the following specification:
|
Wow, this looks like it could be really powerful and convenient. Have you checked whether something similar already exists in related Emacs packages (ebib, reftex, bibtex.el, ...)? |
I've looked into those packages to some extend (not reftex though). Nothing similar found so far. |
I'm not aware of anything, but it's always surprising how much already exists in the Emacs ecosystem. Org-ref may be another thing worth checking. |
Another idea, if you need specific and more complex styles, is to use citeproc. With citeproc-org installed, you can try the function below to create formatted bibliographies of one or more (marked) candidates. It uses chicago-author-date.csl by default (cc: @andras-simonyi).
|
Hello and thanks to @jagrg for bringing this up and cc-ing me! Another alternative could be to use the citeproc-el library directly along the following lines: (defvar helm-bibtex-csl-style "/path/to/csl-file")
(defvar helm-bibtex-csl-locale-dir "/path/to/csl-locales-dir")
(defun helm-bibtex-insert-citeproc-reference (_candidate)
(let* ((locale-getter (citeproc-locale-getter-from-dir helm-bibtex-csl-locale-dir))
(item-getter (citeproc-itemgetter-from-bibtex helm-bibtex-bibliography))
(proc (citeproc-create helm-bibtex-csl-style item-getter locale-getter))
(cites (mapcar (lambda (x) (citeproc-citation-create :cites `(((id . ,x)))))
(helm-marked-candidates))))
(citeproc-append-citations cites proc)
(insert (car (citeproc-render-bib proc 'plain)))))
(helm-add-action-to-source "Insert citeproc reference" 'helm-bibtex-insert-citeproc-reference helm-source-bibtex) This would insert a plain text bibliography, but citeproc-el also supports org-mode, html and latex as output formats, so the format could be adapted to the mode of the current buffer. |
Thanks, this is going to be very useful. So I suppose with this we can use any citation style? Very nice. There's one problem with your function though, |
Yes, any independent CSL style -- dependent styles, which are only aliases to other styles are not (yet) supported. (All the styles in the root of the linked repo are independent ones.) As for the case when |
Thanks, it's working. Could you also explain how to configure FORMATTING-PARAMETERS in |
FORMATTING-PARAMETERS is an alist which is returned together with the formatted bibliography, it contains additional formatting information provided by the used CSL style (line spacing etc.) which can be used by the integrating program, e.g. via style sheets. If you want to change some aspects of the returned bibliography (the car of the returned pair) and none of the existig formatters are suitable then you can define and register a new one -- see |
Sorry, I'm still confused. Using your function above, I want to add a new line between entries. It's not clear where this alist of additional formatting information goes. |
I see -- unfortunately, currently the easiest way to do that would be to define a new formatter, since the built-in |
I think it makes sense to add a new line between entries (that's the case for the org formatter, correct?), or at least give users the option to use something else. |
Fair enough, thanks for the input. I've switched the default separator to "\n\n" for now (in master) and will give some thought to the problem of making this more flexible (without forcing the user into defining a new formatter). -- Update: I've done so, see commit andras-simonyi/citeproc-el@af005f1 . |
Sorry for chiming in so late. Citeproc looks really impressive and the ability to produce citations in almost any format would be a fantastic addition. I'm not familiar with citeproc. Could someone please give me a quick summary of what we'd need to change in helm/ivy-bibtex to make use of citeproc's capabilities? Thanks! |
A lot of the helm-bibtex/org-ref code uses KEY and ENTRY quite heavily, so I'd say the first step is probably to be able to pass KEY and/or ENTRY from helm-bibtex to citeproc. As far as helm-bibtex goes, we could change the "Insert reference" action. Other than that, I see citeproc working with a bibliography:file.bib link to generate formatted bibliographies using the export dispatcher. |
Unfortunately, I'm not familiar with the helm-bibtex codebase but now I've had a cursory look and indeed the "Insert reference" action could call citeproc-el to generate and insert a formatted bibliography from the selected items. It seems that the most efficient way of doing this would be to pass all (KEY, ENTRY) pairs for the selected items (in a citeproc itemgetter closure) since this information seems to be already available (no need for citeproc-el to parse the bibliography files). As for your remark
Could you elaborate on that? Does helm-bibtex have functionality related to org-mode export? Or are you referring to some other type of export? |
I'm referring to the Org-mode exporter (C-c C-e ...). If we add a new link type (see
Fantastic. I'd love to see this added to helm-bibtex. |
Unfortunately, I do not currently have the time to work on this. Too much going on at work. However, feels like preparing a PR, I'd be happy to give input/feedback on it. Otherwise, we'll leave this issue open until I'll find time to do it myself (not before the summer, I'm afraid). |
Sorry for responding only now. As for producing bibliographies from bibliography:file.bib type org-mode links, this should certainly be doable with citeproc-org.
Thanks, I plan to give it a try next month, after adding biblatex support to citeproc-el. |
Thanks, Andras. I think we could easily replace all |
I'd like to refresh this discussion. I have the problem that I cannot add notes to reference entries which are not books, because they lack author and editor, yet these fields are mandatory for the creation of the title string of the note. Thus I get an error. If I try to create a note, Emacs complains about a nil value where a string was expected; the problem is that Quick fix would be to simply allow empty author AND editor fields in the Thinking about it, another good idea would be to wrap the format string for the notes in a condition-case, so that the workflow is not inhibited in case there is some problem with the field definitoins... |
@publicimageltd I think what you're proposing makes sense but it's a different issue than what is discussed in this thread which is about plain-text citations, not note files. (Although I there is some similarity.) Just to better understand your request, what kind of non-book entries do you have in mind? I'm just wondering because I can't think of any document type that has neither author nor editor. In fact, author or editor information is mandatory for most common BibTeX entry types. And are you aware that you can configure |
I use zotero to import website references, which are then automatically exportet to global
Nowadays, it seems quite common to use mere websites as sources, so I think the use case is not that unusual actually. Regarding ((article . "#+TITLE: Notes on: ${author-or-editor} (${year}): ${title}\n\n")
(inreference . "#+TITLE: Notes on ${title}\n\n")
(default . "Whatever you like")) |
I see. Thanks for providing info on the context. I'll think about possible solutions. |
I guess this is a feature request.
Right now,
helm-bibtex
only lets you stringify an entry in APA style when choosing "Insert reference". It would great to be able to choose from a larger set of styles, or even to easily define your own style (something that JabRef allows for).I also noticed that
helm-bibtex
always treats fields as obligatory, so that I have to post-process the reference string now and then. Optional fields like editors in proceedings should be printed only when they exist.Thanks for this excellent package!
The text was updated successfully, but these errors were encountered: