org-export: Add a new predicate to test if an headline is low level

* contrib/lisp/org-export.el (org-export-low-level-p): New function.
* EXPERIMENTAL/org-e-latex.el (org-e-latex-headline): Make use of new function.
This commit is contained in:
Nicolas Goaziou 2012-01-15 18:39:57 +01:00
parent e9ed31f8b9
commit 5e970e407a
2 changed files with 17 additions and 6 deletions

View File

@ -1040,9 +1040,7 @@ holding contextual information."
;; Case 2. This is a deep sub-tree: export it as a list item. ;; Case 2. This is a deep sub-tree: export it as a list item.
;; Also export as items headlines for which no section ;; Also export as items headlines for which no section
;; format has been found. ;; format has been found.
((or (not section-fmt) ((or (not section-fmt) (org-export-low-level-p headline info))
(and (wholenump (plist-get info :headline-levels))
(> level (plist-get info :headline-levels))))
;; Build the real contents of the sub-tree. ;; Build the real contents of the sub-tree.
(let ((low-level-body (let ((low-level-body
(concat (concat

View File

@ -2053,9 +2053,9 @@ INFO is the plist used as a communication channel."
;; headline, while `org-export-number-to-roman' allows to convert it ;; headline, while `org-export-number-to-roman' allows to convert it
;; to roman numbers. ;; to roman numbers.
;; `org-export-first-sibling-p' and `org-export-last-sibling-p' are ;; `org-export-low-level-p', `org-export-first-sibling-p' and
;; two useful predicates when it comes to fulfill the ;; `org-export-last-sibling-p' are three useful predicates when it
;; `:headline-levels' property. ;; comes to fulfill the `:headline-levels' property.
(defun org-export-get-relative-level (headline info) (defun org-export-get-relative-level (headline info)
"Return HEADLINE relative level within current parsed tree. "Return HEADLINE relative level within current parsed tree.
@ -2063,6 +2063,19 @@ INFO is a plist holding contextual information."
(+ (org-element-get-property :level headline) (+ (org-element-get-property :level headline)
(or (plist-get info :headline-offset) 0))) (or (plist-get info :headline-offset) 0)))
(defun org-export-low-level-p (headline info)
"Non-nil when HEADLINE is considered as low level.
A low level headlines has a relative level greater than
`:headline-levels' property value.
Return value is the difference between HEADLINE relative level
and the last level being considered as high enough, or nil."
(let ((limit (plist-get info :headline-levels)))
(when (wholenump limit)
(let ((level (org-export-get-relative-level headline info)))
(and (> level limit) (- level limit))))))
(defun org-export-get-headline-number (headline info) (defun org-export-get-headline-number (headline info)
"Return HEADLINE numbering as a list of numbers. "Return HEADLINE numbering as a list of numbers.
INFO is a plist holding contextual information." INFO is a plist holding contextual information."