Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2013-08-31 14:34:37 +02:00
commit 580b7fce95
2 changed files with 38 additions and 8 deletions

View File

@ -4766,14 +4766,14 @@ information.
Return a list of all exportable headlines as parsed elements.
Footnote sections, if any, will be ignored."
(unless (wholenump n) (setq n (plist-get info :headline-levels)))
(org-element-map (plist-get info :parse-tree) 'headline
(lambda (headline)
(unless (org-element-property :footnote-section-p headline)
;; Strip contents from HEADLINE.
(let ((relative-level (org-export-get-relative-level headline info)))
(unless (> relative-level n) headline))))
info))
(let ((limit (plist-get info :headline-levels)))
(setq n (if (wholenump n) (min n limit) limit))
(org-element-map (plist-get info :parse-tree) 'headline
#'(lambda (headline)
(unless (org-element-property :footnote-section-p headline)
(let ((level (org-export-get-relative-level headline info)))
(and (<= level n) headline))))
info)))
(defun org-export-collect-elements (type info &optional predicate)
"Collect referenceable elements of a determined type.

View File

@ -2602,6 +2602,36 @@ Another text. (ref:text)
info))))
;;; Tables of Contents
(ert-deftest test-org-export/collect-headlines ()
"Test `org-export-collect-headlines' specifications."
;; Standard test.
(should
(= 2
(length
(org-test-with-parsed-data "* H1\n** H2"
(org-export-collect-headlines info)))))
;; Do not collect headlines below optional argument.
(should
(= 1
(length
(org-test-with-parsed-data "* H1\n** H2"
(org-export-collect-headlines info 1)))))
;; Never collect headlines below maximum headline level.
(should
(= 1
(length
(org-test-with-parsed-data "#+OPTIONS: H:1\n* H1\n** H2"
(org-export-collect-headlines info)))))
(should
(= 1
(length
(org-test-with-parsed-data "#+OPTIONS: H:1\n* H1\n** H2"
(org-export-collect-headlines info 2))))))
;;; Templates