Function: org-export-get-footnote-number

org-export-get-footnote-number is a byte-compiled function defined in ox.el.gz.

Signature

(org-export-get-footnote-number FOOTNOTE INFO &optional DATA BODY-FIRST)

Documentation

Return number associated to a footnote.

FOOTNOTE is either a footnote reference or a footnote definition. INFO is the plist containing export state.

Number is unique throughout the whole parse tree, or DATA, when non-nil.

By default, as soon as a new footnote reference is encountered, counting process moves into its definition. However, if BODY-FIRST is non-nil, this step is delayed until the end of the process, leading to a different order when footnotes are nested.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(defun org-export-get-footnote-number (footnote info &optional data body-first)
  "Return number associated to a footnote.

FOOTNOTE is either a footnote reference or a footnote definition.
INFO is the plist containing export state.

Number is unique throughout the whole parse tree, or DATA, when
non-nil.

By default, as soon as a new footnote reference is encountered,
counting process moves into its definition.  However, if
BODY-FIRST is non-nil, this step is delayed until the end of the
process, leading to a different order when footnotes are nested."
  (let ((count 0)
	(seen)
	(label (org-element-property :label footnote)))
    (catch 'exit
      (org-export--footnote-reference-map
       (lambda (f)
	 (let ((l (org-element-property :label f)))
	   (cond
	    ;; Anonymous footnote match: return number.
	    ((and (not l) (not label) (eq footnote f)) (throw 'exit (1+ count)))
	    ;; Labels match: return number.
	    ((and label l (string= label l)) (throw 'exit (1+ count)))
	    ;; Otherwise store label and increase counter if label
	    ;; wasn't encountered yet.
	    ((not l) (cl-incf count))
	    ((not (member l seen)) (push l seen) (cl-incf count)))))
       (or data (plist-get info :parse-tree)) info body-first))))