org-export: Limit depth of headline collection to headline level

* contrib/lisp/org-export.el (org-export-collect-headlines): By
  default, limit depth of headline collection to last headline level.
* contrib/lisp/org-e-html.el (org-e-html-toc): Small refactoring.
This commit is contained in:
Nicolas Goaziou 2012-08-24 09:33:58 +02:00
parent 5b19471358
commit 3f40057adc
2 changed files with 7 additions and 5 deletions

View File

@ -1123,8 +1123,7 @@ that uses these same face definitions."
(format "<span class=\"%s\">%s</span>" todo-type headline)))))
(defun org-e-html-toc (depth info)
(let* ((headlines (org-export-collect-headlines
info (and (wholenump depth) depth)))
(let* ((headlines (org-export-collect-headlines info depth))
(toc-entries
(loop for headline in headlines collect
(list (org-e-html-format-headline--wrap

View File

@ -4075,17 +4075,20 @@ return nil."
INFO is a plist used as a communication channel.
When non-nil, optional argument N must be an integer. It
specifies the depth of the table of contents.
When optional argument N is an integer, it specifies the depth of
the table of contents. Otherwise, it is set to the value of the
last headline level. See `org-export-headline-levels' for more
information.
Return a list of all exportable headlines as parsed elements."
(unless (wholenump n) (setq n (plist-get info :headline-levels)))
(org-element-map
(plist-get info :parse-tree)
'headline
(lambda (headline)
;; Strip contents from HEADLINE.
(let ((relative-level (org-export-get-relative-level headline info)))
(unless (and n (> relative-level n)) headline)))
(unless (> relative-level n) headline)))
info))
(defun org-export-collect-elements (type info &optional predicate)