Browse Source

Merge branch 'master' of orgmode.org:org-mode

Bastien Guerry 10 years ago
parent
commit
9347072882
1 changed files with 39 additions and 11 deletions
  1. 39 11
      lisp/ox-org.el

+ 39 - 11
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."
     (property-drawer . org-org-identity)
     (quote-block . 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.
@@ -181,6 +182,33 @@ as a communication channel."
 	(org-string-nw-p (plist-get info :creator))
 	(format "\n# %s\n" (plist-get info :creator)))))
 
+(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 body-only ext-plist)