From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gbivMw3e4WBEYwEAgWs5BA (envelope-from ) for ; Sun, 04 Jul 2021 18:13:01 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id yNLvLg3e4WCuKQAAB5/wlQ (envelope-from ) for ; Sun, 04 Jul 2021 16:13:01 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0165821375 for ; Sun, 4 Jul 2021 18:13:01 +0200 (CEST) Received: from localhost ([::1]:38502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m04jq-0005IV-Qk for larch@yhetil.org; Sun, 04 Jul 2021 12:12:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m04jA-0005IH-JT for emacs-orgmode@gnu.org; Sun, 04 Jul 2021 12:12:16 -0400 Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]:36492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m04j8-0004zH-47 for emacs-orgmode@gnu.org; Sun, 04 Jul 2021 12:12:16 -0400 Received: by mail-ua1-x935.google.com with SMTP id g21so6011102uaw.3 for ; Sun, 04 Jul 2021 09:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=DvFyXZU4RJ7J0dS4XgZFeV2DvwOew64abto+7HDCv0c=; b=TFiSZRLn6hmfbjXOOyH7z1Ct/n35PbjXxx4ZuRTyO7l/PyWnyIAmUOf2Tz/EYNGHbu 3Yd1qHcEj6JI6fhFMVqBPP0y3DuKzW4/oS6C4/UCmh/SJcU26PT0H5iptcJlHpAqZRO1 F7ldiIsuwvm5rvn7xtAqHsDyy306rtexfH4khAbrXqIjCP75L5WmMo5IyH83HiImD6T7 wTku5f9Wkxfnis1sPimzxYvtPmb2SexDD94pRlH4atNo01IjXmdpBoPSdAOfrbLk38nc vCxYnJPyrmsUrDwM65htAgrbpnfEDwrGQbhNaRLyyR8hVLaptcIH0X0R88XeaafIUDP+ 2dpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=DvFyXZU4RJ7J0dS4XgZFeV2DvwOew64abto+7HDCv0c=; b=a1+3XVJLdgfjMZ5FCG9kc9e3BqyPXS8nC3FcPv1YqV6/7m3wzeW/7wsRKBd8uISNpf iWwYrrhlW30aZl68ulxOvNnIAghJeSOkFYfKI06nW1VPmbna1pwm7Kr6M8/meswJkmrZ uk/oJMYlga9lmpKR17fAlEcX0znn+eOWUNxEuGKNlodYwrvkwP7fz9rWpeTao5O/aY3+ lmqA+w2EnI0eT8xMSeaLig61sN7U5Y44qudhj0Aa85NQRaFyYxroM0H6qIQy6uyfSE2Q V/1zoPwsVS9W0QA6J7nEBKRknp7A35egNECEVjKBNuj7J2bWrWQpg1+Lpo5JmqydII2O bk2Q== X-Gm-Message-State: AOAM533hnC5w5CJ0CNP1hpyw0Vz+lTHf17vtGPKfkHeWsKg8ehEaiZOt aRcN5PIEYAIBGMzzlIDD8++Ze19UlGBLJsPOTbU= X-Google-Smtp-Source: ABdhPJwszwlMOnqEiK0am+V40ZWFkaekYwXPM443BdMbF/UDVfizh4K5quCl2ZGyTQwEfvFFpNCLum/TCWVhVxvJ7yA= X-Received: by 2002:ab0:60d9:: with SMTP id g25mr7661550uam.102.1625415132793; Sun, 04 Jul 2021 09:12:12 -0700 (PDT) MIME-Version: 1.0 References: <87r1gfx27r.fsf@wi.uni-muenster.de> <87h7haw83x.fsf@wi.uni-muenster.de> In-Reply-To: <87h7haw83x.fsf@wi.uni-muenster.de> From: Matt Price Date: Sun, 4 Jul 2021 12:12:01 -0400 Message-ID: Subject: Re: modify citation links in a derived HTML backend To: Matt Price , Org Mode Content-Type: multipart/alternative; boundary="0000000000009a4fc705c64e737e" Received-SPF: pass client-ip=2607:f8b0:4864:20::935; envelope-from=moptop99@gmail.com; helo=mail-ua1-x935.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625415181; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=DvFyXZU4RJ7J0dS4XgZFeV2DvwOew64abto+7HDCv0c=; b=ofV0yTFPnrBNaZyE/azLvGmuXk1nTSMFNRznwoAJxL5yydrQnfpd8F49KILmwXARw+RZx+ PnGfsnDIzBFV8aWFs+NPnKgWeZ7Hxzf48eWNQZVNzD7kx8Q7jngxjErtqzXcNzbjA/TQoq DMVXXbMH1UV36AUwmV69JHKrzQVgjQGWw27X6XC/PetFNbjULOmmEf9uPBLhLjCLsvSGtX hoARdqkpuwpHsIPen2karxNDRMexK98Q9brGwbbSIxhbf5lHEkegeW+4FWHbNJS3skmzpq j4+OOiyZc8uw4oPg1Z/rLUHGNcTzwBXk815uopBPpMxNUiuNC7/NP+drj+bXlg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625415181; a=rsa-sha256; cv=none; b=diIoS+frqI6CfdFHpOITgV/h2WY3rQKwmF2robRNuBv78HSV6HtCx0YsJL3pACR+rGXwWf IlJuHaJfbuUaAJJmSAt8R2D8OsMxKozuRJzpIGy4uXHPb36fuNa3inPYmHaYTNTk1mwhO0 c+OwIStnyLom+2KLkZBNrtfo2jqyr3fBWAgbxfhW1HiFCnl3M7HCWjUFZR2MSNkBz31Jgw o55v4lY4eknJ+6gG83YFHt+Cp5k9e56zrL5knSaZXiXxyZ5TeETqEB9DtUkcBFYMtV9gdw 5+pus9e6zx8J5aIZl0xqQewO0jLRA1JmHOdtUr9GcgYzP8w3y3n/QQDDRaxGVw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=TFiSZRLn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.61 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=TFiSZRLn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 0165821375 X-Spam-Score: -1.61 X-Migadu-Scanner: scn0.migadu.com X-TUID: wsykznGM7UKJ --0000000000009a4fc705c64e737e Content-Type: text/plain; charset="UTF-8" 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? --0000000000009a4fc705c64e737e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sun, Jul 4, 2021 at 8:56 AM Jens L= echtenboerger <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 me= antime
> I've also come up with what seems to be at least a semi-viable hac= k for
> adding native CSL citation support to org-re-reveal. It involves creat= ing
> 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 hav= e
> 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?=C2=A0 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!

<= div>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.
<= br>
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 e= xplanation):

- the new syntax and processors are a= vailable 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 lik= ely for some time, the best citation processor for html export is defined i= n `oc-csl.el` and relies on the citeproc-el library.=C2=A0 My code will onl= y have an effect if the org file contains lines like
------------= --
#+bibliography: food-studies.bib
#+cite_export: csl &qu= ot;/home/matt/src/styles/chicago-author-date-mod.csl"
------= ----------
- oc-csl.el relies on citeproc-el to actually process = the citations.=C2=A0
- citeproc-el is a fairly complex packa= ge 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/citepr= oc-formatters.el), which, importantly, uses lexical binding. That file = defines:
- and a *variable* citeproc-fmt--formatters-alist (https://github.com/andras-simonyi/= citeproc-el/blob/0857973409e3ef2ef0238714f2ef7ff724230d1c/citeproc-formatte= rs.el#L232) that creates a set of formatters using citeproc-formmater-f= un-create, bassing it the value of citeproc-fmt--html-alist as raw material= for the html formatter.
<= br>
The latter is what we need = to change for our export -- we want to change just one of the lambda functi= ons used by the formatter for the duration of export, without updating the = global value of citeproc-fmt--formatters-alist.

Becau= se all these variables are lexically bound -- making the resultant closure = values pretty confusing for me to inspect -- and because the process of cre= ating a formatter is a bit complex, I was a little=C2=A0 confused about how= best to modify the code, and I'm still not quite sure how to go about = it.=C2=A0 It's pretty easy to do this using the dash library:

-----
(let ((org-re-re= veal-citeproc-fmt-alist
=C2=A0 =C2=A0 =C2=A0 =C2=A0(--map-when (eq =C2= =A0(car it) 'cited-item-no)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 `(cited-item-no . ,(lambda (x y) (concat "<a href=3D\&qu= ot;#slide-bibliography\">" x "</a>")))
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citeproc-fmt--html-alist)))
=C2=A0[do some exporting stu= ff])
-------
or just

-----
(defcustom org-re-reveal-citeproc-fmt-alist
=C2=A0(--map-when (eq =C2=A0(car it) 'cit= ed-item-no)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 `(cited-ite= m-no . ,(lambda (x y) (concat "<a href=3D\"#slide-bibliography= \">" x "</a>")))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 citeproc-fmt--html-alist)
:group org-re-reveal
:type alist)
------

But I'= m not sure how best to do it without that.=C2=A0

<= div>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 l= ikely to error out in many circumstances. Probably I should, in org-re-reve= al-export-to-html,=C2=A0 at least test if the function citeproc-formatter-f= un-create is bound, so:

----------
(let = ((citeproc-fmt--formatters-alist
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (and= (functionp 'citeproc-formatter-create)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0`((html . ,(citeproc-formatter-create
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :rt (citeproc-f= ormatter-fun-create org-re-reveal-citeproc-fmt-alist)
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :bib #'citeproc-fmt--h= tml-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?
=

--0000000000009a4fc705c64e737e--