From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Lawrence Subject: Re: More questions about CSL and org-mode Date: Mon, 07 Dec 2015 11:55:42 -0800 Message-ID: <874mfuuj7l.fsf@berkeley.edu> References: <87r3izupne.fsf@berkeley.edu> <87oae3uonn.fsf@berkeley.edu> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a61sX-0007mV-Qs for emacs-orgmode@gnu.org; Mon, 07 Dec 2015 14:55:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a61sU-0003uP-LG for emacs-orgmode@gnu.org; Mon, 07 Dec 2015 14:55:21 -0500 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]:32895) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a61sU-0003u7-Fw for emacs-orgmode@gnu.org; Mon, 07 Dec 2015 14:55:18 -0500 Received: by pacce3 with SMTP id ce3so662205pac.0 for ; Mon, 07 Dec 2015 11:55:17 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: John Kitchin Cc: Org Mode Hi John, John Kitchin writes: > Thanks. > > Its an interesting jam. You want to have multiple outputs as a > possibility, but there isn't a robust markup that readily works across > all backends. Yes, indeed. > On export the in-text citations are transformed to unique text blobs, > e.g. uuids, and the document exported. The only important features of > these blobs is that they do not get changed on export, and they are > unique because we replace them later. > > The strings in the bibliography entry are "exported" to convert the > org-markup to the output format. The in-text citations, expanded > bibliography and style are sent to the citation processor, which outputs > replacements and a formatted bibliography in the desired output format. > > Finally, you replace each uuid with the appropriate replacement, and > insert the bibliography where it belongs. That should be the final > document. IIUC, the problem with this approach is that it will not work well when the citation style is note-based rather than inline. The main motivation for going "back to Org" is that note-based styles require the document structure to change as a result of citation processing: new footnotes have to be inserted, and existing ones have to be renumbered. That is relatively hard to do if the rest of the document is already in the target format (except with LaTeX). By doing citation processing early in the export process and converting the results to Org, we can rely on Org's footnote processing to handle this later in the export process. As far as I can see, if it weren't for note-based styles, this approach would work fine. (Indeed, it is pretty much what the existing org-cite code does, except that the mapping between citations and their replacements is done with Lisp data structures rather than via string replacement in the output buffer. I stopped work on that right about the time I realized the existing approach wouldn't work very well with note-based styles.) But given the problem about nested formatting, going back to Org at the level of text replacements doesn't work. In other words: both of the simple-minded approaches (process citations directly to text in the target format, or process them to Org text, then let Org convert them to the target format) face problems. I think probably what we'll have to do to accommodate both note-based styles and the possibility of nested formatting is to get the results of citation processing in some unambiguous format like HTML or JSON, then parse it, and then use the result to directly modify the parse tree for the Org document before continuing the export process. I can't see an easier way...can anyone else? Best, Richard