summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2011-02-10 13:19:37 +0100
committerBastien Guerry <bzg@altern.org>2011-02-11 01:27:15 +0100
commitda8dc7bba72613131f97a28f1c4a912b8d85d7cc (patch)
treecb6a454af84de64ccd7d20efd95380d5807c83af
parentf9c833dad015b7847f659e06bac8690b9d7d3794 (diff)
downloadorg-mode-da8dc7bba72613131f97a28f1c4a912b8d85d7cc.tar.gz
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.)
-rw-r--r--doc/org.texi11
-rw-r--r--lisp/org-exp.el6
-rw-r--r--lisp/org-html.el137
-rw-r--r--lisp/org-publish.el6
4 files changed, 89 insertions, 71 deletions
diff --git a/doc/org.texi b/doc/org.texi
index bbbf804..f8a7493 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10839,8 +10839,6 @@ respective variable for details.
@vindex org-export-publishing-directory
@vindex org-export-html-preamble
@vindex org-export-html-postamble
-@vindex org-export-html-auto-preamble
-@vindex org-export-html-auto-postamble
@vindex user-full-name
@vindex user-mail-address
@vindex org-export-select-tags
@@ -10888,10 +10886,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}
-@item @code{:preamble} @tab @code{org-export-html-preamble}
-@item @code{:postamble} @tab @code{org-export-html-postamble}
-@item @code{:auto-preamble} @tab @code{org-export-html-auto-preamble}
-@item @code{:auto-postamble} @tab @code{org-export-html-auto-postamble}
+@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}
@@ -11103,8 +11099,7 @@ right place on the web server, and publishing images to it.
:table-of-contents nil
:style "<link rel=\"stylesheet\"
href=\"../other/mystyle.css\" type=\"text/css\"/>"
- :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..79debf9 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 "<h1 class=\"title\">%s</h1>\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" "<h1 class=\"title\">%t</h1>"))
+ "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" "<p class=\"author\">Author: %a (%e)</p>
+<p class=\"date\">Date: %d</p>
+<p class=\"creator\">Generated by %c</p>
+<p class=\"xhtml-validation\">%v</p>
+"))
+ "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
+ "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
+ "Link to HTML validation service."
:group 'org-export-html
- :type '(choice
- (const :tag "Nothing" nil)
- (const :tag "XHTML 1.0" "<p class=\"xhtml-validation\"><a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a></p>")
- (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 <body>. 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 </body>. 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 "<div id=\"postamble\">\n")
- (when (and org-export-author-info author)
- (insert "<p class=\"author\"> "
- (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 "<a href=\"mailto:" e "\">&lt;"
- e "&gt;</a>\n"))
- (split-string email ",+ *"))
- (insert "<a href=\"mailto:" email "\">&lt;"
- email "&gt;</a>\n")))
- (insert "</p>\n"))
- (when (and date org-export-time-stamp-file)
- (insert "<p class=\"date\"> "
- (nth 2 lang-words) ": "
- date "</p>\n"))
- (when org-export-creator-info
- (insert (format "<p class=\"creator\">HTML generated by org-mode %s in emacs %s</p>\n"
- org-version emacs-major-version)))
- (when org-export-html-validation-link
- (insert org-export-html-validation-link "\n"))
- (insert "</div>"))
-
- (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</div>\n</body>\n</html>\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 "<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 . ,org-export-html-validation-link))))
+ (insert "</div>")
+ )))
+
+ (if org-export-html-with-timestamp
+ (insert org-export-html-html-helper-timestamp))
+
+ (insert "\n</div>\n</body>\n</html>\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'