Function: org-org--add-missing-sections

org-org--add-missing-sections is a byte-compiled function defined in ox-org.el.gz.

Signature

(org-org--add-missing-sections TREE BACKEND INFO)

Documentation

Ensure each headline has an associated section.

TREE is the parse tree being exported.

Footnotes relative to the headline are inserted in the section, using org-org-section. However, this function is not called if the headline doesn't contain any section in the first place, so we make sure it is always called.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-org.el.gz
(defun org-org--add-missing-sections (tree _backend _info)
  "Ensure each headline has an associated section.

TREE is the parse tree being exported.

Footnotes relative to the headline are inserted in the section,
using `org-org-section'.  However, this function is not called if
the headline doesn't contain any section in the first place, so
we make sure it is always called."
  (org-element-map tree 'headline
    (lambda (h)
      (let ((first-child (car (org-element-contents h)))
	    (new-section (org-element-create 'section)))
	(pcase (org-element-type first-child)
	  (`section nil)
	  (`nil (org-element-adopt-elements h new-section))
	  (_ (org-element-insert-before new-section first-child))))))
  tree)