|
@@ -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 "\"><"
|
|
|
- e "></a>\n"))
|
|
|
- (split-string email ",+ *"))
|
|
|
- (insert "<a href=\"mailto:" email "\"><"
|
|
|
- email "></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)
|