浏览代码

contrib/lisp/org-export: Add footnote number to footnotes definitions collection

* contrib/lisp/org-export.el
  (org-export-collect-footnote-definitions): Change key to footnote
  number, retrieved with `org-export-get-footnote-number'.  Also, do
  not use beginning position as label for inline footnotes, as those
  are weak identifiers.
Nicolas Goaziou 13 年之前
父节点
当前提交
5136d2ee41
共有 1 个文件被更改,包括 5 次插入17 次删除
  1. 5 17
      contrib/lisp/org-export.el

+ 5 - 17
contrib/lisp/org-export.el

@@ -2110,14 +2110,11 @@ Point is at buffer's beginning when BODY is applied."
 ;; additional information relative to a footnote reference.
 
 (defun org-export-collect-footnote-definitions (data info)
-  "Return an alist between footnote label and its definition.
+  "Return an alist between footnote numbers, labels and definitions.
 
 DATA is the parse tree from which definitions are collected.
 INFO is the plist used as a communication channel.
 
-As anonymous footnotes have no label, the key used is that case
-is their beginning position.
-
 Definitions are sorted by order of references.  They either
 appear as Org data \(transcoded with `org-export-data'\) or as
 a secondary string for inlined footnotes \(transcoded with
@@ -2126,19 +2123,10 @@ ignored."
   (org-element-map
    data 'footnote-reference
    (lambda (footnote local)
-     (cond
-      ;; Definition already collected.
-      ((not (org-export-footnote-first-reference-p footnote local)) nil)
-      ;; Reference has a label: Use it as a key, and get the
-      ;; corresponding definition.
-      ((org-element-get-property :label footnote)
-       (cons (org-element-get-property :label footnote)
-             (org-export-get-footnote-definition footnote local)))
-      ;; No label: This is an anonymous footnote. Use beginning
-      ;; position as the key and inline definition (a secondary
-      ;; string) as its value.
-      (t (cons (org-element-get-property :begin footnote)
-               (org-element-get-property :inline-definition footnote)))))
+     (when (org-export-footnote-first-reference-p footnote local)
+       (list (org-export-get-footnote-number footnote local)
+	     (org-element-get-property :label footnote)
+	     (org-export-get-footnote-definition footnote local))))
    info))
 
 (defun org-export-footnote-first-reference-p (footnote-reference info)