Browse Source

org-export: Generalize fallback footnote definition to all exporters

* contrib/lisp/org-export.el (org-export-get-footnote-definition):
  Provide a fallback definition when none can be found.
* contrib/lisp/org-e-latex.el (org-e-latex-footnote-reference): Revert
  change made in 30ef385ee03ea1f92e07f368413c065630bc01b8 since it is
  now handled at the export framework level.
* testing/lisp/test-org-export.el: Add test.
Nicolas Goaziou 12 years ago
parent
commit
423756dd11
3 changed files with 14 additions and 9 deletions
  1. 2 6
      contrib/lisp/org-e-latex.el
  2. 5 2
      contrib/lisp/org-export.el
  3. 7 1
      testing/lisp/test-org-export.el

+ 2 - 6
contrib/lisp/org-e-latex.el

@@ -1371,13 +1371,9 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	   thereis (memq (org-element-type parent)
 			 '(footnote-reference footnote-definition table-cell)))
      "\\footnotemark")
-    ;; Otherwise, define it with \footnote command.  If no definition
-    ;; is available, notify it with an intrusive fallback one.
+    ;; Otherwise, define it with \footnote command.
     (t
-     (let ((def (or (org-export-get-footnote-definition footnote-reference info)
-		    '("FOOTNOTE DEFINITION NOT FOUND."))))
-       (unless (eq (org-element-type def) 'org-data)
-	 (setq def (cons 'org-data (cons nil def))))
+     (let ((def (org-export-get-footnote-definition footnote-reference info)))
        (concat
 	(format "\\footnote{%s}" (org-trim (org-export-data def info)))
 	;; Retrieve all footnote references within the footnote and

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

@@ -3267,10 +3267,13 @@ INFO is the plist used as a communication channel."
 
 (defun org-export-get-footnote-definition (footnote-reference info)
   "Return definition of FOOTNOTE-REFERENCE as parsed data.
-INFO is the plist used as a communication channel."
+INFO is the plist used as a communication channel.  If no such
+definition can be found, return the \"DEFINITION NOT FOUND\"
+string."
   (let ((label (org-element-property :label footnote-reference)))
     (or (org-element-property :inline-definition footnote-reference)
-        (cdr (assoc label (plist-get info :footnote-definition-alist))))))
+        (cdr (assoc label (plist-get info :footnote-definition-alist)))
+	"DEFINITION NOT FOUND.")))
 
 (defun org-export-get-footnote-number (footnote info)
   "Return number associated to a footnote.

+ 7 - 1
testing/lisp/test-org-export.el

@@ -850,7 +850,13 @@ Paragraph[fn:1]"
 	       (org-export-backend-translate-table 'test)))
 	(forward-line)
 	(should (equal "ParagraphOut of scope\n"
-		       (org-export-as 'test 'subtree)))))))
+		       (org-export-as 'test 'subtree)))))
+    ;; 6. Footnotes without a definition should be provided a fallback
+    ;;    definition.
+    (should
+     (org-test-with-parsed-data "[fn:1]"
+       (org-export-get-footnote-definition
+	(org-element-map tree 'footnote-reference 'identity info t) info)))))