From 423756dd1193035f21a00b7a153943f2b46d58de Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 30 Jan 2013 14:17:30 +0100 Subject: [PATCH] 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. --- contrib/lisp/org-e-latex.el | 8 ++------ contrib/lisp/org-export.el | 7 +++++-- testing/lisp/test-org-export.el | 8 +++++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/contrib/lisp/org-e-latex.el b/contrib/lisp/org-e-latex.el index 7697b1672..14f21e230 100644 --- a/contrib/lisp/org-e-latex.el +++ b/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 diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index 35a1bd8fa..db78b9086 100644 --- a/contrib/lisp/org-export.el +++ b/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. diff --git a/testing/lisp/test-org-export.el b/testing/lisp/test-org-export.el index 858ccda8c..1a91a8c7e 100644 --- a/testing/lisp/test-org-export.el +++ b/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)))))