Ihor Radchenko <yanta...@posteo.net> writes: > David Masterson <dsmaster...@icloud.com> writes: > >> Is there a way to export a section of an Org file only if the export >> backend is *NOT* a particular backend? For instance, some things don't >> work in Texinfo, but are fine in HTML and LATEX. >> >> Is there a generalized IF for processing an Org file? > > Nothing out of the box, but you can, for example, introduce a custom > attribute that will control that. > > #+attr_all: :export (not texinfo) > Some text _not_ for texinfo here. > > Then, > (defun yant/org-export-conditional-export (data backend info) > (org-element-map data org-element-all-elements > (lambda (el) > (pcase (car (read-from-string (or (org-export-read-attribute :attr_all > el :export) "nil"))) > (`nil t) > (`(not . ,backends) > (when (member backend backends) > (org-element-extract el))) > (backends > (unless (member backend backends) > (org-element-extract el))))) > info nil nil t) > data) > (add-to-list 'org-export-filter-parse-tree-functions > #'yant/org-export-conditional-export)
Interesting. My elisp is not strong, so a few questions: 1. Are you saying attr_all does not exist in Org and this code is creating it? 2. I assume 'backends' is a list I must create, correct? 3. What does the last argument ('t') to org-element-map do? 4. Doesn't org-element-map return data, so isn't the last data unnecessary? Thanks -- David Masterson