-
Notifications
You must be signed in to change notification settings - Fork 9
Rendering isolated references with a modified html formatter
András Simonyi edited this page Mar 15, 2024
·
1 revision
The following example shows how a new, slightly modified html formatter can be defined, registered, and used for rendering isolated references.
(require 'citeproc)
;; Create and register a 'modified-html' citeproc-el formatter
(setq modified-html-alist
(cons `(href . ,(lambda (x y) (concat "<a target=\'_blank\' href=\"" y "\">" x "</a>")))
citeproc-fmt--html-alist))
(push `(modified-html . ,(citeproc-formatter-create
:rt (citeproc-formatter-fun-create modified-html-alist)
:bib #'citeproc-fmt--html-bib-formatter))
citeproc-fmt--formatters-alist)
;; Use the created formatter to render some items' bib entries
(let* ((lg (citeproc-locale-getter-from-dir "/dir/to/csl_locales"))
(style (citeproc-create-style "/path/to/style_to_use.csl" lg))
(ig (citeproc-hash-itemgetter-from-any "/path/to/bibtex.bib"))
(items (funcall ig (list "bibtex_key_1" "bibtex_key_2"))))
(mapcar (lambda (item) (citeproc-render-item (cdr item) style 'bib 'modified-html))
items))