emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: add a heading w/ #+print_bibliography to parse tree on export


From: John Kitchin
Subject: Re: add a heading w/ #+print_bibliography to parse tree on export
Date: Fri, 30 Jul 2021 21:01:36 -0400

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


On Fri, Jul 30, 2021 at 8:18 PM Matt Price <moptop99@gmail.com> 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!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]