org-export: Allow user to explicitely ignore parts of parse tree
commit5313dc9d091ad7d8c26f17eb5d0f09be9a596f3b
authorNicolas Goaziou <n.goaziou@gmail.com>
Sat, 25 Feb 2012 12:08:40 +0000 (25 13:08 +0100)
committerNicolas Goaziou <n.goaziou@gmail.com>
Sat, 25 Feb 2012 13:55:21 +0000 (25 14:55 +0100)
tree011f81f0dd330618f62e0ab3fff66d18d1bb6111
parent9f7965a80ea46f509f7b00787d9f7287871e291f
org-export: Allow user to explicitely ignore parts of parse tree

* contrib/lisp/org-export.el (org-export-collect-tree-properties):
  Do not overwrite any user's ignore list.
* testing/contrib/lisp/test-org-export.el: Add test.

A good way to populate `:ignore-list' is through the use of
`org-export-filter-parse-tree-functions', with the help of
`org-element-map' and `org-export-ignore-element'.  As an example, the
following code will skip every headline containing the word "note"
in its title during a LaTeX export:

(defun user-skip-note-headlines (data backend info)
  ;; For now LaTeX back-end is called `e-latex'.
  (when (eq backend 'test)
    ;; Traverse the parse tree, adding to ignore list any headline
    ;; matching criteria.
    (org-element-map
     data 'headline
     (lambda (headline)
       (when (string-match "\\<note\\>"
                           (org-element-property :raw-value headline))
         (org-export-ignore-element headline info)))
     info))
  ;; Return original DATA.
  data)

Then install it in parse-tree filters:

(add-to-list 'user-skip-note-headlines org-export-filter-parse-tree-functions)

Back-end delevopers will install it via `org-BACKEND-filters-alist'
where BACKEND stands for the name of the back-end considered.  Se
`org-export-filters-alist' for more information.
contrib/lisp/org-export.el
testing/contrib/lisp/test-org-export.el