Function: org-export--collect-headline-numbering

org-export--collect-headline-numbering is a byte-compiled function defined in ox.el.gz.

Signature

(org-export--collect-headline-numbering DATA OPTIONS)

Documentation

Return numbering of all exportable, numbered headlines in a parse tree.

DATA is the parse tree. OPTIONS is the plist holding export options.

Return an alist whose key is a headline and value is its associated numbering (in the shape of a list of numbers) or nil for a footnotes section.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(defun org-export--collect-headline-numbering (data options)
  "Return numbering of all exportable, numbered headlines in a parse tree.

DATA is the parse tree.  OPTIONS is the plist holding export
options.

Return an alist whose key is a headline and value is its
associated numbering \(in the shape of a list of numbers) or nil
for a footnotes section."
  (let ((numbering (make-vector org-export-max-depth 0)))
    (org-element-map data 'headline
      (lambda (headline)
	(when (and (org-export-numbered-headline-p headline options)
		   (not (org-element-property :footnote-section-p headline)))
	  (let ((relative-level
		 (1- (org-export-get-relative-level headline options))))
	    (cons
	     headline
	     (cl-loop
	      for n across numbering
	      for idx from 0 to org-export-max-depth
	      when (< idx relative-level) collect n
	      when (= idx relative-level) collect (aset numbering idx (1+ n))
	      when (> idx relative-level) do (aset numbering idx 0))))))
      options)))