If you want to cite a reference like this , you
need to do some extra configuration. The manual is clearly written.
The user can eval the following code to automatically generate a
reference list.
1
2
3
4
5
6
7
8
9
10
11
| (with-eval-after-load 'ox
(defun my/org-ref-process-buffer--html (backend)
"Preprocess `org-ref' citations to HTML format.
Do this only if the export backend is `html' or a derivative of
that."
;; `ox-hugo' is derived indirectly from `ox-html'.
;; ox-hugo <- ox-blackfriday <- ox-md <- ox-html
(when (org-export-derived-backend-p backend 'html)
(org-ref-process-buffer 'html)))
(add-to-list 'org-export-before-parsing-hook #'my/org-ref-process-buffer--html))
|
To check an org-mode entry has a reference, see wr/does-buffer-has-a-reference-p
:
1
2
3
4
5
6
| (defun wr/does-buffer-has-a-reference-p ()
(if (org-element-map (org-element-parse-buffer) 'link
(lambda (lnk)
(when (assoc (org-element-property :type lnk) org-ref-cite-types)
lnk)))
t nil))
|
Now, we can add something to the refile commmand such that it will
generate a reference list if you cite something in the blog post, but
do nothing if you do not have any citation in the original post.
1
2
3
4
5
6
7
| (progn
(org-end-of-subtree)
(insert "\n")
(cl-loop repeat (+ 1 (org-current-level))
do (insert "\*"))
(insert " Reference(s) \n [[bibliography:/path/lib.bib]]")
(beginning-of-buffer))
|
Now, you don’t worry about the reference any more. Happy writting and citation.
(Moore et al., 2010)
References
Moore, E. B., de la Llave, E., Welke, K., Scherlis, D. A., & Molinero, V. (2010). Freezing, melting and structure of ice in a hydrophilic nanopore.
Phys. Chem. Chem. Phys.,
12(16), 4124–4134.
https://doi.org/10.1039/B919724A