On Sun, Jul 4, 2021 at 8:56 AM Jens Lechtenboerger < lechten@wi.uni-muenster.de> wrote: > On 2021-07-03, Matt Price wrote: > > > I've added some comments in the issue you linked to, but in the meantime > > I've also come up with what seems to be at least a semi-viable hack for > > adding native CSL citation support to org-re-reveal. It involves creating > > two new variables and then let-setting `citeproc-fmt--formatters-alist` > in > > `org-re-reveal-export-to-html`. Something similar could presumably be > done > > in other derived backends. > > > > I find it quite hackish and I don't know whether perhaps some more > general > > solution could be found, but in any case here is the code, which I have > > inserted into org-re-reveal.el locally: > > Thank you for sharing your code, Matt! > > What is the general state of this new citation handling with respect > to export backends? Did you create the settings for HTML from > scratch or did you take inspiration from HTML export functionality? > I guess that basic support should go into ox-html, while small > modifications could than take care of specifics for reveal.js > presentations... > > Best wishes > Jens > Thanks Jens! So, there is a rather complicated chain of dependencies and I'm not sure how best to procee in the specific case of org-re-reveal. Here is how I understand the current state of affairs (and I think Bruce, Nicolas, and Andras are all likely to have corrections to my explanation): - the new syntax and processors are available in the wip-cite-new branch of hte org git repo, and will likely be merged into the master branch pretty soon. - at present, and likely for some time, the best citation processor for html export is defined in `oc-csl.el` and relies on the citeproc-el library. My code will only have an effect if the org file contains lines like -------------- #+bibliography: food-studies.bib #+cite_export: csl "/home/matt/src/styles/chicago-author-date-mod.csl" ---------------- - oc-csl.el relies on citeproc-el to actually process the citations. - citeproc-el is a fairly complex package with many moving parts. It supports processing of citations in html and latex backends, but not in any others (I think this is right!) - citation formatting is handled in the file citation-formatters. el ( https://github.com/andras-simonyi/citeproc-el/blob/master/citeproc-formatters.el), which, importantly, uses lexical binding. That file defines: - a *structure* citeproc-formatter ( https://github.com/andras-simonyi/citeproc-el/blob/0857973409e3ef2ef0238714f2ef7ff724230d1c/citeproc-formatters.el#L35 ), - a *function* citeproc-formatter-fun-create ( https://github.com/andras-simonyi/citeproc-el/blob/0857973409e3ef2ef0238714f2ef7ff724230d1c/citeproc-formatters.el#L51 ) - a *constant* citeproc-fmt--html-alist ( https://github.com/andras-simonyi/citeproc-el/blob/0857973409e3ef2ef0238714f2ef7ff724230d1c/citeproc-formatters.el#L142 ) - and a *variable* citeproc-fmt--formatters-alist ( https://github.com/andras-simonyi/citeproc-el/blob/0857973409e3ef2ef0238714f2ef7ff724230d1c/citeproc-formatters.el#L232) that creates a set of formatters using citeproc-formmater-fun-create, bassing it the value of citeproc-fmt--html-alist as raw material for the html formatter. The latter is what we need to change for our export -- we want to change just one of the lambda functions used by the formatter for the duration of export, without updating the global value of citeproc-fmt--formatters-alist. Because all these variables are lexically bound -- making the resultant closure values pretty confusing for me to inspect -- and because the process of creating a formatter is a bit complex, I was a little confused about how best to modify the code, and I'm still not quite sure how to go about it. It's pretty easy to do this using the dash library: ----- (let ((org-re-reveal-citeproc-fmt-alist (--map-when (eq (car it) 'cited-item-no) `(cited-item-no . ,(lambda (x y) (concat "" x ""))) citeproc-fmt--html-alist))) [do some exporting stuff]) ------- or just ----- (defcustom org-re-reveal-citeproc-fmt-alist (--map-when (eq (car it) 'cited-item-no) `(cited-item-no . ,(lambda (x y) (concat "" x ""))) citeproc-fmt--html-alist) :group org-re-reveal :type alist) ------ But I'm not sure how best to do it without that. In any case, the code I have provided here and in gitlab ( https://gitlab.com/oer/org-re-reveal/-/merge_requests/33) is quite hackish and doubtless likely to error out in many circumstances. Probably I should, in org-re-reveal-export-to-html, at least test if the function citeproc-formatter-fun-create is bound, so: ---------- (let ((citeproc-fmt--formatters-alist (and (functionp 'citeproc-formatter-create) `((html . ,(citeproc-formatter-create :rt (citeproc-formatter-fun-create org-re-reveal-citeproc-fmt-alist) :bib #'citeproc-fmt--html-bib-formatter)))))) ....do stuff) (actually, I simplified my merge request to use all this code). Does that help the explanation? And what do you think?