Function: org-texinfo-headline

org-texinfo-headline is a byte-compiled function defined in ox-texinfo.el.gz.

Signature

(org-texinfo-headline HEADLINE CONTENTS INFO)

Documentation

Transcode a HEADLINE element from Org to Texinfo.

CONTENTS holds the contents of the headline. INFO is a plist holding contextual information.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-texinfo.el.gz
;;;; Headline

(defun org-texinfo-headline (headline contents info)
  "Transcode a HEADLINE element from Org to Texinfo.
CONTENTS holds the contents of the headline.  INFO is a plist
holding contextual information."
  (cond
   ((org-element-property :footnote-section-p headline) nil)
   ((org-not-nil (org-export-get-node-property :COPYING headline t)) nil)
   (t
    (let* ((index (let ((i (org-export-get-node-property :INDEX headline t)))
		    (and (member i '("cp" "fn" "ky" "pg" "tp" "vr")) i)))
	   (numbered? (org-export-numbered-headline-p headline info))
	   (notoc? (org-export-excluded-from-toc-p headline info))
	   (command
	    (and
             (not (org-export-low-level-p headline info))
	     (let ((sections (org-texinfo--sectioning-structure info)))
               (pcase (nth (1- (org-export-get-relative-level headline info))
			   sections)
		 (`(,numbered ,unnumbered ,unnumbered-no-toc ,appendix)
		  (cond
		   ((org-not-nil
		     (org-export-get-node-property :APPENDIX headline t))
		    appendix)
		   (numbered? numbered)
		   (index unnumbered)
		   (notoc? unnumbered-no-toc)
		   (t unnumbered)))
		 (`nil nil)
		 (_ (user-error "Invalid Texinfo class specification: %S"
				(plist-get info :texinfo-class)))))))
	   (todo
	    (and (plist-get info :with-todo-keywords)
		 (let ((todo (org-element-property :todo-keyword headline)))
		   (and todo (org-export-data todo info)))))
	   (todo-type (and todo (org-element-property :todo-type headline)))
	   (tags (and (plist-get info :with-tags)
		      (org-export-get-tags headline info)))
	   (priority (and (plist-get info :with-priority)
			  (org-element-property :priority headline)))
	   (text (org-texinfo--sanitize-title
		  (org-element-property :title headline) info))
	   (full-text
	    (funcall (plist-get info :texinfo-format-headline-function)
		     todo todo-type priority text tags))
	   (contents
	    (concat "\n"
		    (if (org-string-nw-p contents) (concat "\n" contents) "")
		    (and index (format "\n@printindex %s\n" index))))
           (node (org-texinfo--get-node headline info)))
      (if (not command)
	  (concat (and (org-export-first-sibling-p headline info)
		       (format "@%s\n" (if numbered? 'enumerate 'itemize)))
		  (format "@item\n@anchor{%s}%s\n" node full-text)
		  contents
		  (if (org-export-last-sibling-p headline info)
		      (format "@end %s" (if numbered? 'enumerate 'itemize))
		    "\n"))
	(concat
	 ;; Even if HEADLINE is using @subheading and al., leave an
	 ;; anchor so cross-references in the Org document still work.
	 (format (if notoc? "@anchor{%s}\n" "@node %s\n") node)
	 (format command full-text)
	 contents))))))