Browse Source

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.
Nicolas Goaziou 13 years ago
parent
commit
5e970e407a
2 changed files with 17 additions and 6 deletions
  1. 1 3
      EXPERIMENTAL/org-e-latex.el
  2. 16 3
      contrib/lisp/org-export.el

+ 1 - 3
EXPERIMENTAL/org-e-latex.el

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

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

@@ -2053,9 +2053,9 @@ INFO is the plist used as a communication channel."
 ;; headline, while `org-export-number-to-roman' allows to convert it
 ;; to roman numbers.
 
-;; `org-export-first-sibling-p' and `org-export-last-sibling-p' are
-;; two useful predicates when it comes to fulfill the
-;; `:headline-levels' property.
+;; `org-export-low-level-p', `org-export-first-sibling-p' and
+;; `org-export-last-sibling-p' are three useful predicates when it
+;; comes to fulfill the `:headline-levels' property.
 
 (defun org-export-get-relative-level (headline info)
   "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)
      (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)
   "Return HEADLINE numbering as a list of numbers.
 INFO is a plist holding contextual information."