瀏覽代碼

Clean handling :html-pre/postamble options wrt author/email/creator-info.

* org-html.el (org-export-html-preamble)
(org-export-html-postamble): now default to `nil'.
(org-export-as-html): when :html-pre/postamble is nil, fall
back on the default pre/postamble, which depends on the
:author-info, :email-info, :creator-info options.

* org-exp.el (org-export-plist-vars): reorder the alist.

* org.texi (Export options): better document :html-preamble
and :html-postamble: setting these options will override any
:author-info, :email-info and :creator-info options for the
HTML export.
Bastien Guerry 14 年之前
父節點
當前提交
5953798522
共有 3 個文件被更改,包括 80 次插入58 次删除
  1. 21 12
      doc/org.texi
  2. 4 4
      lisp/org-exp.el
  3. 55 42
      lisp/org-html.el

+ 21 - 12
doc/org.texi

@@ -9437,11 +9437,17 @@ d:         @r{turn on/off inclusion of drawers}
 @end example
 @noindent
 These options take effect in both the HTML and @LaTeX{} export, except for
-@code{TeX} and @code{LaTeX}, which are respectively @code{t} and @code{nil}
-for the @LaTeX{} export.  The default values for these and many other options
-are given by a set of variables.  For a list of such variables, the
-corresponding OPTIONS keys and also the publishing keys (@pxref{Project
-alist}), see the constant @code{org-export-plist-vars}.
+@code{TeX} and @code{LaTeX} options, which are respectively @code{t} and
+@code{nil} for the @LaTeX{} export.
+
+Setting @code{org-export-html-pre/postamble} to @code{t} will override the
+values of the @code{author}, @code{email} and @code{creator} options in HTML
+export: it will use @code{org-export-html-pre/postamble-format} instead.
+
+The default values for these and many other options are given by a set of
+variables.  For a list of such variables, the corresponding OPTIONS keys and
+also the publishing keys (@pxref{Project alist}), see the constant
+@code{org-export-plist-vars}.
 
 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
 calling an export command, the subtree can overrule some of the file's export
@@ -10711,7 +10717,7 @@ and many other properties of a project.
 * Sources and destinations::    From here to there
 * Selecting files::             What files are part of the project?
 * Publishing action::           Setting the function doing the publishing
-* Publishing options::          Tweaking HTML export
+* Publishing options::          Tweaking HTML/@LaTeX{} export
 * Publishing links::            Which links keep working after publishing?
 * Sitemap::                     Generating a list of all pages
 * Generating an index::         An index that reaches across pages
@@ -10920,6 +10926,8 @@ respective variable for details.
 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
+@item @code{:author}                @tab @code{user-full-name}
+@item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
 @item @code{:author-info}           @tab @code{org-export-author-info}
 @item @code{:email-info}            @tab @code{org-export-email-info}
 @item @code{:creator-info}          @tab @code{org-export-creator-info}
@@ -10932,15 +10940,13 @@ respective variable for details.
 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
 @item @code{:html-extension}        @tab @code{org-export-html-extension}
+@item @code{:html-preamble}         @tab @code{org-export-html-preamble}
+@item @code{:html-postamble}        @tab @code{org-export-html-postamble}
 @item @code{:xml-declaration}       @tab @code{org-export-html-xml-declaration}
 @item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
-@item @code{:html-preamble}         @tab @code{org-export-html-preamble}
-@item @code{:html-postamble}        @tab @code{org-export-html-postamble}
-@item @code{:author}                @tab @code{user-full-name}
-@item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
 @item @code{:select-tags}           @tab @code{org-export-select-tags}
 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
 @item @code{:latex-image-options}   @tab @code{org-export-latex-image-default-option}
@@ -10948,8 +10954,11 @@ respective variable for details.
 
 Most of the @code{org-export-with-*} variables have the same effect in
 both HTML and @LaTeX{} exporters, except for @code{:TeX-macros} and
-@code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
-@LaTeX{} export.
+@code{:LaTeX-fragments} options, respectively @code{nil} and @code{t} in the
+@LaTeX{} export.  See @code{org-export-plist-vars} to check this list of
+options.
+
+
 
 @vindex org-publish-project-alist
 When a property is given a value in @code{org-publish-project-alist},

+ 4 - 4
lisp/org-exp.el

@@ -627,6 +627,8 @@ table.el tables."
     (:skip-before-1st-heading "skip"	  org-export-skip-text-before-1st-heading)
     (:fixed-width	      ":"	  org-export-with-fixed-width)
     (:timestamps	      "<"	  org-export-with-timestamps)
+    (:author		      nil	  user-full-name)
+    (:email		      nil	  user-mail-address)
     (:author-info	      "author"	  org-export-author-info)
     (:email-info	      "email"	  org-export-email-info)
     (:creator-info	      "creator"	  org-export-creator-info)
@@ -641,15 +643,13 @@ table.el tables."
     (:convert-org-links	      nil	  org-export-html-link-org-files-as-html)
     (:inline-images	      nil	  org-export-html-inline-images)
     (:html-extension	      nil	  org-export-html-extension)
+    (:html-preamble	      nil	  org-export-html-preamble)
+    (:html-postamble	      nil	  org-export-html-postamble)
     (:xml-declaration         nil	  org-export-html-xml-declaration)
     (:html-table-tag	      nil	  org-export-html-table-tag)
     (:expand-quoted-html      "@"	  org-export-html-expand)
     (:timestamp		      nil	  org-export-html-with-timestamp)
     (:publishing-directory    nil	  org-export-publishing-directory)
-    (:html-preamble	      nil	  org-export-html-preamble)
-    (:html-postamble	      nil	  org-export-html-postamble)
-    (:author		      nil	  user-full-name)
-    (:email		      nil	  user-mail-address)
     (:select-tags	      nil	  org-export-select-tags)
     (:exclude-tags	      nil	  org-export-exclude-tags)
 

+ 55 - 42
lisp/org-html.el

@@ -343,10 +343,11 @@ CSS classes, then this prefix can be very useful."
   :group 'org-export-html
   :type 'string)
 
-(defcustom org-export-html-preamble t
+(defcustom org-export-html-preamble nil
   "Non-nil means insert a preamble in HTML export.
-The format of the preamble is set as `org-export-html-preamble-format'.
-Setting :html-preamble in publishing projects will override this."
+If this is a string, use it as a formatting string it instead of
+`org-export-html-preamble-format'.  Setting :html-preamble in
+publishing projects will override this."
   :group 'org-export-html
   :type 'boolean)
 
@@ -361,10 +362,11 @@ like that: \"%%\"."
   :group 'org-export-html
   :type 'string)
 
-(defcustom org-export-html-postamble t
+(defcustom org-export-html-postamble nil
   "Non-nil means insert a postamble in HTML export.
-The format of the postamble is set as `org-export-html-postamble-format'.
-Setting :html-postamble in publishing projects will override this."
+If this is a string, use it as a formatting string it instead of
+`org-export-html-postamble-format'.  Setting :html-postamble in
+publishing projects will override this."
   :group 'org-export-html
   :type 'boolean)
 
@@ -1274,19 +1276,20 @@ lang=\"%s\" xml:lang=\"%s\">
 		      "\n")
 		   "")))
 
-	;; insert html preamble (for now the title)
-	(when (plist-get opt-plist :html-preamble)
-	  (let* ((html-preamble (plist-get opt-plist :html-preamble))
-		 (html-preamble-format
-		  (if (stringp html-preamble)
-		      html-preamble
-		    (or (cadr (assoc (nth 0 lang-words)
-				     org-export-html-preamble-format))
-			(cadr (assoc "en" org-export-html-preamble-format))))))
-	    (insert (format-spec html-preamble-format
-				 `((?t . ,title)
-				   (?a . ,author) (?d . ,date) (?e . ,email)))))))
-
+	;; insert html preamble
+	(if (plist-get opt-plist :html-preamble)
+	    (let* ((html-preamble (plist-get opt-plist :html-preamble))
+		   (html-preamble-format
+		    (if (stringp html-preamble)
+			html-preamble
+		      (cadr (or (assoc (nth 0 lang-words)
+				       org-export-html-preamble-format)
+				(assoc "en" org-export-html-preamble-format))))))
+	      (insert (format-spec html-preamble-format
+				   `((?t . ,title)
+				     (?a . ,author) (?d . ,date) (?e . ,email)))))
+	  (insert  "<h1 class=\"title\">" title "</h1>")))
+      
       (if (and org-export-with-toc (not body-only))
 	  (progn
 	    (push (format "<h%d>%s</h%d>\n"
@@ -1675,29 +1678,39 @@ lang=\"%s\" xml:lang=\"%s\">
 
       ;; export html postamble
       (unless body-only
-	(when (plist-get opt-plist :html-postamble)
-	  (let* ((html-postamble (plist-get opt-plist :html-postamble))
-		 (html-postamble-format
-		  (if (stringp html-postamble)
-		      html-postamble
-		    (or (cadr (assoc (nth 0 lang-words)
-				     org-export-html-postamble-format))
-			(cadr (assoc "en" org-export-html-postamble-format)))))
-		 (email
-		  (mapconcat (lambda(e)
-			       (format "<a href=\"mailto:%s\">%s</a>" e e))
-			     (split-string email ",+ *")
-			     ", "))
-		 (creator-info
-		  (concat "Org version " org-version " with Emacs version "
-			  (number-to-string emacs-major-version))))
-	    (insert "<div id=\"postamble\">\n")
-	    (insert (format-spec html-postamble-format
-				 `((?a . ,author) (?e . ,email)
-				   (?d . ,date)   (?c . ,creator-info)
-				   (?v . ,html-validation-link))))
-	    (insert "</div>")
-	    )))
+	(if (plist-get opt-plist :html-postamble)
+	    (let* ((html-postamble (plist-get opt-plist :html-postamble))
+		   (html-postamble-format
+		    (if (stringp html-postamble)
+			html-postamble
+		      (or (cadr (assoc (nth 0 lang-words)
+				       org-export-html-postamble-format))
+			  (cadr (assoc "en" org-export-html-postamble-format)))))
+		   (email
+		    (mapconcat (lambda(e)
+				 (format "<a href=\"mailto:%s\">%s</a>" e e))
+			       (split-string email ",+ *")
+			       ", "))
+		   (creator-info
+		    (concat "Org version " org-version " with Emacs version "
+			    (number-to-string emacs-major-version))))
+	      (insert "<div id=\"postamble\">\n")
+	      (insert (format-spec html-postamble-format
+				   `((?a . ,author) (?e . ,email)
+				     (?d . ,date)   (?c . ,creator-info)
+				     (?v . ,html-validation-link))))
+	      (insert "</div>"))
+	  ;; fall back on default postamble
+	  (insert "<div id=\"postamble\">\n")
+	  (when (and (plist-get opt-plist :author-info) author)
+	    (insert "<p class=\"author\">" (nth 1 lang-words) ": " author "</p>\n"))
+	  (when (and (plist-get opt-plist :email-info) email)
+	    (insert "<p class=\"mailto:" email "\">&lt;" email "&gt;</p>\n"))
+	  (when (plist-get opt-plist :creator-info)
+	    (insert "<p class=\"creator\">"
+		    (concat "Org version " org-version " with Emacs version "
+			    (number-to-string emacs-major-version) "</p>\n")))
+	  (insert html-validation-link "\n</div>")))
 
       (if org-export-html-with-timestamp
 	  (insert org-export-html-html-helper-timestamp))