Pārlūkot izejas kodu

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.
Nicolas Goaziou 12 gadi atpakaļ
vecāks
revīzija
3f40057adc
2 mainītis faili ar 7 papildinājumiem un 5 dzēšanām
  1. 1 2
      contrib/lisp/org-e-html.el
  2. 6 3
      contrib/lisp/org-export.el

+ 1 - 2
contrib/lisp/org-e-html.el

@@ -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

+ 6 - 3
contrib/lisp/org-export.el

@@ -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)