reddit / emacs

How can I automatically print the bibliography with org mode ?

xaltsc · 2022-05-31 10:18
Hey, I'm running Emacs 28.1 with org 9.5.2 (and citeproc 20220124.721). I'm mostly intersted in the case where the export backend is html, and, albeit, adding \`#+print\_bibliography:\` works fine, it's a bit tedious to add at the bottom of each file with its own outline, etc... ​ Is it possible to add an option, either to the whole html backend or just to a project, to automatically add a bibliography section at the bottom of each html file, without having to do what I've described above ?
udco · 2022-05-31 11:23
Sounds like something org capture templates can solve?
xaltsc · 2022-05-31 13:38
Not quite, it doesn't solve the problem for already existing org files and it doesn't target specifically the html backend.
attento_redaz · 2022-06-02 15:26
What about adding the required insertion code to the `org-export-before-parsing-hook`? (See the [manual](https://orgmode.org/manual/Advanced-Export-Configuration.html) for details.)
xaltsc · 2022-06-03 10:29
That's exactly what I wanted to avoid doing, but I guess I don't really have the choice. Here's the code I came up with, for reference: ```elisp (setq xc/biblio-section (s-join "\n" (list "* Bibliographie" "#+print_bibliography:"))) (defun xc/org-has-citations-p () (org-element-map (org-element-parse-buffer) 'citation #'identity)) (defun xc/org-export-biblio-in-html (backend) (when (and (org-export-derived-backend-p backend 'html) (xc/org-has-citations-p)) (save-excursion (goto-char (point-max)) (insert "\n" xc/biblio-section)))) (add-hook 'org-export-before-parsing-hook #'xc/org-export-biblio-in-html) ```
bdarcus · 2022-06-03 11:16
>That's exactly what I wanted to avoid doing, but I guess I don't really have the choice. You could always suggest a feature on the org list?