瀏覽代碼

Revert "Fix bug when inserting the output of a custom function for the pre/postamble."

This reverts commit 701830d5a2681ba0ff2e5112fbd4279eb958801a.
Bastien Guerry 13 年之前
父節點
當前提交
9aec216b04
共有 1 個文件被更改,包括 18 次插入11 次删除
  1. 18 11
      lisp/org-html.el

+ 18 - 11
lisp/org-html.el

@@ -1352,21 +1352,28 @@ PUB-DIR is set, use this as the publishing directory."
 	(when (plist-get opt-plist :html-preamble)
 	  (let ((html-pre (plist-get opt-plist :html-preamble))
 		html-pre-real-contents)
-	    (setq html-pre-real-contents
-		  (if (stringp html-pre)
-		      (format-spec html-pre `((?t . ,title) (?a . ,author)
-					      (?d . ,date) (?e . ,email)))
+	    (cond ((stringp html-pre)
+		   (setq html-pre-real-contents
+			 (format-spec html-pre `((?t . ,title) (?a . ,author)
+						 (?d . ,date) (?e . ,email)))))
+		  ((functionp html-pre)
+		   (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
+		   (funcall html-pre)
+		   (insert "\n</div>\n"))
+		  (t
+		   (setq html-pre-real-contents
 		    (format-spec
 		     (or (cadr (assoc (nth 0 lang-words)
 				      org-export-html-preamble-format))
 			 (cadr (assoc "en" org-export-html-preamble-format)))
 		     `((?t . ,title) (?a . ,author)
-		       (?d . ,date) (?e . ,email)))))
-	    ;; Always insert the preamble
-	    (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
-	    (insert (if (functionp html-pre) (funcall html-pre)
-		      (insert html-pre-real-contents)))
-	    (insert "\n</div>\n")))
+		       (?d . ,date) (?e . ,email))))))
+	    ;; don't output an empty preamble DIV
+	    (unless (and (functionp html-pre)
+			 (equal html-pre-real-contents ""))
+	      (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
+	      (insert html-pre-real-contents)
+	      (insert "\n</div>\n"))))
 
 	;; begin wrap around body
 	(insert (format "\n<div id=\"%s\">"
@@ -1809,7 +1816,7 @@ PUB-DIR is set, use this as the publishing directory."
 					  (?d . ,date)   (?c . ,creator-info)
 					  (?v . ,html-validation-link)))))
 		  ((functionp html-post)
-		   (insert (funcall html-post)))
+		   (funcall html-post))
 		  ((eq html-post 'auto)
 		   ;; fall back on default postamble
 		   (when (plist-get opt-plist :time-stamp-file)