>From 823130bde38a5fb644292f4fa98b29f418c36262 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 10 Feb 2011 13:19:37 +0100 Subject: [PATCH] Rewrite the handling of HTML preamble/postamble. * org-html.el (org-export-html-auto-preamble) (org-export-html-auto-postamble): Remove. (org-export-html-preamble, org-export-html-postamble): Turn into custom variables. Update the docstrings. (org-export-html-preamble-format) (org-export-html-postamble-format): New custom variables. (org-export-as-html): Use org-export-html-postamble-format and org-export-html-preamble-format. (org-export-html-title-format): delete. * org-exp.el (org-export-plist-vars): Remove :auto-preamble and :auto-postamble. Rename :preamble and :postamble to :html-preamble and :html-postamble. * org-publish.el (org-publish-project-alist): Remove :auto-preamble and :auto-postamble. Rename :preamble and :postamble to :html-preamble and :html-postamble. * org.texi (Publishing options): replace :preamble and :auto-preamble by :html-preamble (same for postamble.) --- doc/org.texi | 11 +--- lisp/org-exp.el | 6 +-- lisp/org-html.el | 137 ++++++++++++++++++++++++++++++-------------------- lisp/org-publish.el | 6 +-- 4 files changed, 89 insertions(+), 71 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 8838295..a029e4b 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10837,8 +10837,6 @@ respective variable for details. @vindex org-export-publishing-directory @vindex org-export-html-preamble @vindex org-export-html-postamble address@hidden org-export-html-auto-preamble address@hidden org-export-html-auto-postamble @vindex user-full-name @vindex user-mail-address @vindex org-export-select-tags @@ -10886,10 +10884,8 @@ respective variable for details. @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} address@hidden @code{:preamble} @tab @code{org-export-html-preamble} address@hidden @code{:postamble} @tab @code{org-export-html-postamble} address@hidden @code{:auto-preamble} @tab @code{org-export-html-auto-preamble} address@hidden @code{:auto-postamble} @tab @code{org-export-html-auto-postamble} address@hidden @code{:html-preamble} @tab @code{org-export-html-preamble} address@hidden @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} @@ -11101,8 +11097,7 @@ right place on the web server, and publishing images to it. :table-of-contents nil :style "" - :auto-preamble t - :auto-postamble nil) + :html-preamble t) ("images" :base-directory "~/images/" diff --git a/lisp/org-exp.el b/lisp/org-exp.el index c38436a..6350983 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -629,10 +629,8 @@ table.el tables." (:expand-quoted-html "@" org-export-html-expand) (:timestamp nil org-export-html-with-timestamp) (:publishing-directory nil org-export-publishing-directory) - (:preamble nil org-export-html-preamble) - (:postamble nil org-export-html-postamble) - (:auto-preamble nil org-export-html-auto-preamble) - (:auto-postamble nil org-export-html-auto-postamble) + (: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) diff --git a/lisp/org-html.el b/lisp/org-html.el index 58c65bf..508165a 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -29,6 +29,7 @@ ;;; Code: (require 'org-exp) +(require 'format-spec) (eval-when-compile (require 'cl)) @@ -342,8 +343,41 @@ CSS classes, then this prefix can be very useful." :group 'org-export-html :type 'string) -(defcustom org-export-html-title-format "

%s

\n" - "Format for typesetting the document title in HTML export." +(defcustom org-export-html-preamble t + "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." + :group 'org-export-html + :type 'boolean) + +(defcustom org-export-html-preamble-format + '(("en" "

%t

")) + "The format for the HTML preamble. + +%t stands for the title." + :group 'org-export-html + :type 'string) + +(defcustom org-export-html-postamble t + "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." + :group 'org-export-html + :type 'boolean) + +(defcustom org-export-html-postamble-format + '(("en" "

Author: %a (%e)

+

Date: %d

+

Generated by %c

+

%v

+")) + "The format for the HTML postamble. + +%a stands for the author. +%e stands for the email(s). +%d stands for the date. +%c will be replaced by information about Org/Emacs. +%v will be replaced by `org-export-html-validation-link'." :group 'org-export-html :type 'string) @@ -469,13 +503,11 @@ When nil, also column one will use data tags." :group 'org-export-tables :type 'boolean) -(defcustom org-export-html-validation-link nil - "Non-nil means add validation link to postamble of HTML exported files." +(defcustom org-export-html-validation-link + "Validate XHTML 1.0" + "Link to HTML validation service." :group 'org-export-html - :type '(choice - (const :tag "Nothing" nil) - (const :tag "XHTML 1.0" "

Validate XHTML 1.0

") - (string :tag "Specify full HTML"))) + :type 'string) (defcustom org-export-html-with-timestamp nil "If non-nil, write timestamp into the exported HTML text. @@ -534,19 +566,6 @@ with a link to this URL." (const :tag "Keep internal css" nil) (string :tag "URL or local href"))) -;;; Variables, constants, and parameter plists - -(defvar org-export-html-preamble nil - "Preamble, to be inserted just after . Set by publishing functions. -This may also be a function, building and inserting the preamble.") -(defvar org-export-html-postamble nil - "Postamble, to be inserted just before . Set by publishing functions. -This may also be a function, building and inserting the postamble.") -(defvar org-export-html-auto-preamble t - "Should default preamble be inserted? Set by publishing functions.") -(defvar org-export-html-auto-postamble t - "Should default postamble be inserted? Set by publishing functions.") - ;;; Hooks (defvar org-export-html-after-blockquotes-hook nil @@ -1241,11 +1260,18 @@ lang=\"%s\" xml:lang=\"%s\"> "\n") ""))) - (org-export-html-insert-plist-item opt-plist :preamble opt-plist) - - (when (plist-get opt-plist :auto-preamble) - (if title (insert (format org-export-html-title-format - (org-html-expand title)))))) + ;; 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 . ,(org-html-expand title)) + (?a . ,author) (?d . ,date) (?e . ,email))))))) (if (and org-export-with-toc (not body-only)) (progn @@ -1698,36 +1724,37 @@ lang=\"%s\" xml:lang=\"%s\"> (let ((bib (org-export-html-get-bibliography))) (when bib (insert "\n" bib "\n"))) + + ;; export html postamble (unless body-only - (when (plist-get opt-plist :auto-postamble) - (insert "
\n") - (when (and org-export-author-info author) - (insert "

" - (nth 1 lang-words) ": " author "\n") - (when (and org-export-email-info email (string-match "\\S-" email)) - (if (listp (split-string email ",+ *")) - (mapc (lambda(e) - (insert "<" - e ">\n")) - (split-string email ",+ *")) - (insert "<" - email ">\n"))) - (insert "

\n")) - (when (and date org-export-time-stamp-file) - (insert "

" - (nth 2 lang-words) ": " - date "

\n")) - (when org-export-creator-info - (insert (format "

HTML generated by org-mode %s in emacs %s

\n" - org-version emacs-major-version))) - (when org-export-html-validation-link - (insert org-export-html-validation-link "\n")) - (insert "
")) - - (if org-export-html-with-timestamp - (insert org-export-html-html-helper-timestamp)) - (org-export-html-insert-plist-item opt-plist :postamble opt-plist) - (insert "\n\n\n\n")) + (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 "%s" e e)) + (split-string email ",+ *") + ", ")) + (creator-info + (concat "Org version " org-version " with Emacs version " + (number-to-string emacs-major-version)))) + (insert "
\n") + (insert (format-spec html-postamble-format + `((?a . ,author) (?e . ,email) + (?d . ,date) (?c . ,creator-info) + (?v . ,org-export-html-validation-link)))) + (insert "
") + ))) + + (if org-export-html-with-timestamp + (insert org-export-html-html-helper-timestamp)) + + (insert "\n\n\n\n") (unless (plist-get opt-plist :buffer-will-be-killed) (normal-mode) diff --git a/lisp/org-publish.el b/lisp/org-publish.el index 98e09f3..a7aaee2 100644 --- a/lisp/org-publish.el +++ b/lisp/org-publish.el @@ -155,10 +155,8 @@ learn more about their use and default values. :expand-quoted-html `org-export-html-expand' :timestamp `org-export-html-with-timestamp' :publishing-directory `org-export-publishing-directory' - :preamble `org-export-html-preamble' - :postamble `org-export-html-postamble' - :auto-preamble `org-export-html-auto-preamble' - :auto-postamble `org-export-html-auto-postamble' + :html-preamble `org-export-html-preamble' + :html-postamble `org-export-html-postamble' :author `user-full-name' :email `user-mail-address' -- 1.7.4