From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CISkBh+hBGGsOgEAgWs5BA (envelope-from ) for ; Sat, 31 Jul 2021 03:02:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id gD5xAh+hBGHgCgAA1q6Kng (envelope-from ) for ; Sat, 31 Jul 2021 01:02:23 +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 E5D5C199A6 for ; Sat, 31 Jul 2021 03:02:21 +0200 (CEST) Received: from localhost ([::1]:56202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9dOP-0002Zc-3B for larch@yhetil.org; Fri, 30 Jul 2021 21:02:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9dNw-0002ZS-EE for emacs-orgmode@gnu.org; Fri, 30 Jul 2021 21:01:52 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:52882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m9dNt-0000nO-Rn for emacs-orgmode@gnu.org; Fri, 30 Jul 2021 21:01:52 -0400 Received: by mail-wm1-x334.google.com with SMTP id n11so6973587wmd.2 for ; Fri, 30 Jul 2021 18:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=andrew-cmu-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=b4Uqc2CXEubuaMW7rlDLbJTXhSvAKz4kYpvWkb4ebIw=; b=DzOx1Ip1w/RGdjNiQ9pUR28W9pwkQJFSaNJLT6vZmCsNmh54EUnXGfWwG/0/XTEf4k 4A9Knm77v4YeaLKqndVET+Ioa68PfdAXFNIR540RU136HB4J4+CdpWnQEfFk70w/odS6 6FQvEr7qj292/dQ8vgSQ6qTbWGAHDRWmsBVKIhwGtRUf9QKPqsS6ZHPvXL7GlUKsIRCP ysubiTwdFBHYD9PUDLodkdaTd5VrpDxQ6CS0vMloZr/DaZyd0TwwpWwsxtEGIHIdUOkk P1lE/eYPU0Tqnv8P5+JMzW/6QoKKg0xiJfK9Vi0L5wfcHvHrZHQrBadgHQuIYqU/oe8N lCjQ== 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:cc; bh=b4Uqc2CXEubuaMW7rlDLbJTXhSvAKz4kYpvWkb4ebIw=; b=Jp/HwzJ+XT3J9ZqSjvUkVRNNqM1BXWBV2bj3aAP4EiUydUw979eUBoAPc/FmutttWi kBI/EmIYAATn70y71O2VmAtGuiH+Ls15ZUX4q+W3Jk06u4vK5N02Kzvl3r9J0a+QMDGM j0WQtvsxVcotnQQtet0/kJxGraTD4Up3Ku//kP39gccGwibQN3HMndordzpq1cJZNufo 2UpiP4n0GdA97ixMnxMTY+f4N85qRG1aFQWiDIX5sAymR1qMIFTeuz6tIB/IifS/biBT BSgjBUcjrVsturSsQXJGrSSbU9lAcBUS5hsz6kD4XyRKaA9JyDBLJTw0Rwz9pRyPl62a kG9A== X-Gm-Message-State: AOAM530hLGAuhnFAD9jl34n/1l7W0wA0a4kq1nBkPpSg8KiMhN9Tvo8Q HO8mdmX7wV2OUE8Co7cAu1TxKJMyBsFltQ0h7Vg= X-Google-Smtp-Source: ABdhPJyW2ujc5HpFGiIkXttws67E5GbHfjbtrQtWq2zGWLIIeMeqByvJ5A3R1A5ksuVsQINSzY+b+Z+I0AdOzF25UV8= X-Received: by 2002:a05:600c:3509:: with SMTP id h9mr5531396wmq.81.1627693307326; Fri, 30 Jul 2021 18:01:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: John Kitchin Date: Fri, 30 Jul 2021 21:01:36 -0400 Message-ID: Subject: Re: add a heading w/ #+print_bibliography to parse tree on export To: Matt Price Content-Type: multipart/alternative; boundary="00000000000062f4b505c860e141" Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=johnrkitchin@gmail.com; helo=mail-wm1-x334.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Org Mode 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=1627693342; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=b4Uqc2CXEubuaMW7rlDLbJTXhSvAKz4kYpvWkb4ebIw=; b=KZkxgj/LDC1fjYowcCQMoWAyQy/f4rmzrXUE4xpaLnuN2LhODnpoNsCv0Iz6pe19bcfE+e vvPkr0ywc1M8hRY5Ybp3A/V4T//4AjIqqk8/j4jCXsDNHkErELQJg+Yzbn2TbiorTTiDP8 2dRNoX+iYlkXWqWO3/ZON5a/tjdmnddQ/8zsshJeG84pmhPbInw8H/QYqTgJNnmDw7FqK+ WDM+qq+njtjl+oX6UYE4a2Tq0rX6xJwSuSgFysX194s8agrahzpjlEZFvWWOxCoZKWwkHZ JUHfJ8ZoRYkgqnYGVjilw+4+nMsN36ypohwEi5/RLeyMtSssZpU7lREnIgH3Qg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1627693342; a=rsa-sha256; cv=none; b=AdmDta0Amy5xmhpjWbG+uSTbTmsgoNRx5zEWnSqkLKzaRWfoP0IQ4dIGOEQ49Zptj7gQXJ E286eXEELIIm3IlRB9UgfYViiWyUH51WSe/fqP9A2QV9IVItqgIhVX0ql2kB+KjpwQpLQE ZckWpJGpvTh1g8r5zjQIcYLqxDRe2GCVqJRcyp7t4sh3Prq29uXOBgUCPrcreKsym5QnJD 8IpesGBRIQbRdGA4GNMQ5bO/XpKMfg0MArk4qFA5AB7wB6P1YFpFD4zCm9v/lYOgWrVctP OFGG6OxJl2oW+/8vdtKi+QJusqKeoTofAThV++AhgamdFF/zlJIqZ4hwcknvGA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=andrew-cmu-edu.20150623.gappssmtp.com header.s=20150623 header.b=DzOx1Ip1; 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: -2.52 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=andrew-cmu-edu.20150623.gappssmtp.com header.s=20150623 header.b=DzOx1Ip1; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=andrew.cmu.edu (policy=none); 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: E5D5C199A6 X-Spam-Score: -2.52 X-Migadu-Scanner: scn0.migadu.com X-TUID: TWU/K63jtb9r --00000000000062f4b505c860e141 Content-Type: text/plain; charset="UTF-8" I think the way to do this is to use a function in org-export-before-processing-hook to add it if you don't find it. you can still use org-ml to generate the string that gets inserted. I guess you would just go to the end of the buffer and insert it. John ----------------------------------- Professor John Kitchin (he/him/his) Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Fri, Jul 30, 2021 at 8:18 PM Matt Price wrote: > Goal: > conditionally add a headline with content to parse tree using either > org-export-before-parsing-hook or org-export-filter-parse-tree-functions > > Explanation: > I use org-re-reveal to make lecture slides from subtrees. Often I forget > to add a heading with #+print_bibliography: and as a result org-cite does > not generate the bibliography, and my citations are not wrapped in links. > I'd like to search *either* the parse tree *or* the temporary export > buffer for the #+print_bibliography keyword, and if it's not found, add a > headline to the end of the subtree/parse-tree with the appropriate > information. > > I can easily generate the proper lisp object with the org-ml package: > > (org-ml-build-headline :title '("Sources") > (org-ml-build-section > (org-ml-build-property-drawer > (org-ml-build-node-property "CUSTOM_ID" > "bibliography")) > (org-ml-build-keyword "print_bibliography" "" ) > )) > > And if I want I can turn that into a string by wrapping it in > (org-ml-to-trimmed-string ...) > > However, I'm not sure how best to add it to the exported data. I believe > I can add a function to either org-export-before-parsing-hook or > org-export-filter-parse-tree-functions, but beyond that I'm a bit lost. > It's not immediately obvious how to find the last headline and append > another headline after that headline's section. Looking at the nesting > confuses me somewhat and I'm afraid I'll break the data structure. > > Has anyone done something like this before and do you have ideas? > > Thank you! > --00000000000062f4b505c860e141 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think the=C2=A0way to do this is to use a function = in org-export-before-processing-hook to add it if you don't find it.=C2= =A0=C2=A0

you can still use org-ml to generate the= string that gets inserted. I guess you would just go to the end of the buf= fer and insert it.

John

-----------------------------------
Prof= essor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chem= ical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
4= 12-268-7803


Goal:
conditionally add a headline w= ith content to parse tree using either org-export-before-parsing-hook or or= g-export-filter-parse-tree-functions

Explanation: =
I use org-re-reveal to make lecture slides from subtrees. Of= ten I forget to add a heading with #+print_bibliography: and as a result or= g-cite does not generate the bibliography, and my citations are not wrapped= in links. I'd like to search *either* the parse tree=C2=A0 *or* the te= mporary export buffer for the #+print_bibliography keyword, and if it's= not found, add a headline to the end of the subtree/parse-tree with the ap= propriate information.=C2=A0

I can easily gen= erate the proper lisp object with the org-ml package:

<= div>(org-ml-build-headline :title '("Sources")
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(o= rg-ml-build-section
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-ml-build-property-drawer
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(org-ml-build-node-property "CUSTOM_ID" "bibliography&= quot;))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (org-ml-build-keyword "print_bibliography" &= quot;" )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 ))

And if I want I can= turn that into a string by wrapping it in (org-ml-to-trimmed-string ...)

However, I'm not sure how best to add it to the= exported data.=C2=A0 I believe I can add a function to either org-export-b= efore-parsing-hook or org-export-filter-parse-tree-functions, but beyond th= at I'm a bit lost. It's not immediately obvious how to find the las= t headline and append another headline after that headline's section. L= ooking at the nesting confuses me somewhat and I'm afraid I'll brea= k the data structure.

Has anyone done something li= ke this before and do you have ideas?

Thank you!
--00000000000062f4b505c860e141--