summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2014-05-21 18:33:53 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2014-05-21 18:37:13 +0200
commit844a6494c37b474b738cdd857b3f6b9bdabc038e (patch)
tree0299e957d6c2f70c52c5abf20865e4a4de90ebd2
parent7d6cc7f0bf128e3a713a1c50f2c39f0321955fbb (diff)
downloadorg-mode-844a6494c37b474b738cdd857b3f6b9bdabc038e.tar.gz
ox-org: Fix missing footnote definitions
* lisp/ox-org.el (org-org-headline): Ignore footnote sections. (org-org-section): New function. Some footnote definitions may be outside of the scope of the export and, therefore, do not appear in the generated output. This patch ensures that all footnote definitions appear at the end of the section they belong to. Thanks to Leonard Randall for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/86558
-rw-r--r--lisp/ox-org.el50
1 files changed, 39 insertions, 11 deletions
diff --git a/lisp/ox-org.el b/lisp/ox-org.el
index 3b2e55e..8bd56c2 100644
--- a/lisp/ox-org.el
+++ b/lisp/ox-org.el
@@ -65,7 +65,7 @@ setting of `org-html-htmlize-output-type' is 'css."
(entity . org-org-identity)
(example-block . org-org-identity)
(fixed-width . org-org-identity)
- (footnote-definition . org-org-identity)
+ (footnote-definition . ignore)
(footnote-reference . org-org-identity)
(headline . org-org-headline)
(horizontal-rule . org-org-identity)
@@ -87,7 +87,7 @@ setting of `org-html-htmlize-output-type' is 'css."
(quote-block . org-org-identity)
(quote-section . org-org-identity)
(radio-target . org-org-identity)
- (section . org-org-identity)
+ (section . org-org-section)
(special-block . org-org-identity)
(src-block . org-org-identity)
(statistics-cookie . org-org-identity)
@@ -122,15 +122,16 @@ CONTENTS is its contents, as a string or nil. INFO is ignored."
(defun org-org-headline (headline contents info)
"Transcode HEADLINE element back into Org syntax.
CONTENTS is its contents, as a string or nil. INFO is ignored."
- (unless (plist-get info :with-todo-keywords)
- (org-element-put-property headline :todo-keyword nil))
- (unless (plist-get info :with-tags)
- (org-element-put-property headline :tags nil))
- (unless (plist-get info :with-priority)
- (org-element-put-property headline :priority nil))
- (org-element-put-property headline :level
- (org-export-get-relative-level headline info))
- (org-element-headline-interpreter headline contents))
+ (unless (org-element-property :footnote-section-p headline)
+ (unless (plist-get info :with-todo-keywords)
+ (org-element-put-property headline :todo-keyword nil))
+ (unless (plist-get info :with-tags)
+ (org-element-put-property headline :tags nil))
+ (unless (plist-get info :with-priority)
+ (org-element-put-property headline :priority nil))
+ (org-element-put-property headline :level
+ (org-export-get-relative-level headline info))
+ (org-element-headline-interpreter headline contents)))
(defun org-org-keyword (keyword contents info)
"Transcode KEYWORD element back into Org syntax.
@@ -144,6 +145,33 @@ keywords targeted at other export back-ends."
org-element-block-name-alist))
(org-element-keyword-interpreter keyword nil)))
+(defun org-org-section (section contents info)
+ "Transcode SECTION element back into Org syntax.
+CONTENTS is the contents of the section. INFO is a plist used as
+a communication channel."
+ (concat
+ (org-element-normalize-string contents)
+ ;; Insert footnote definitions appearing for the first time in this
+ ;; section. Indeed, some of them may not be available to narrowing
+ ;; so we make sure all of them are included in the result.
+ (let ((footnotes-alist
+ (org-element-map section 'footnote-reference
+ (lambda (fn)
+ (and (not (org-element-property :inline-definition fn))
+ (org-export-footnote-first-reference-p fn info)
+ (cons (org-element-property :label fn)
+ (org-export-get-footnote-definition fn info))))
+ info)))
+ (and footnotes-alist
+ (concat "\n"
+ (mapconcat
+ (lambda (d)
+ (org-element-normalize-string
+ (concat (format "[%s] "(car d))
+ (org-export-data (cdr d) info))))
+ footnotes-alist "\n"))))
+ (make-string (or (org-element-property :post-blank section) 0) ?\n)))
+
;;;###autoload
(defun org-org-export-as-org (&optional async subtreep visible-only ext-plist)
"Export current buffer to an Org buffer.