diff options
author | Rick Frankel <rick@rickster.com> | 2013-03-16 15:10:53 -0400 |
---|---|---|
committer | Rick Frankel <rick@rickster.com> | 2013-03-16 15:17:44 -0400 |
commit | 67a17cfe857a5e3ad58083207c49ce9148f19f97 (patch) | |
tree | c27b1a71f7910e0cee7cbcb70c7ffdb859e0afb1 | |
parent | 243c4618416cf32bb386590509cc7661d1667776 (diff) | |
download | org-mode-67a17cfe857a5e3ad58083207c49ce9148f19f97.tar.gz |
Update s5 and deck,js slideshow exporters to work with refactored html
backend.
* lisp/ox-html.el (org-html--build-pre/postamble): Add css class to
wrapper div (defaults to `org-pre/postamble-class'). Move spec
building to separate function (`org-html-format-spec').
(org-html-format-spec): New function.
(org-pre/postamble-class): New variable.
* contrib/lisp/ox-deck.el: Replace :html-{pre,post}amble export
options with :deck versions.
(org-deck-postamble): Replaces `org-deck-postamble-template', uses
format-spec (and `org-html-format-spec') instead of custom template
option.
(org-deck-preamble): Replaces `org-deck-postamble-template', uses
format-spec (and `org-html-format-spec') instead of custom template
option.
(org-deck-title-slide-template): Use standard format specs.
(org-deck-template): Use org-html--build-pre/postamble instead of
`org-deck-fill-template'. Use fill-template for title slide (with
standard format specs) instead of custom `org-fill-template'
(org-deck-template-alist): Delete.
(org-deck-postamble-template): Delete.
(org-deck-preamble-template): Delete.
* contrib/lisp/ox-s5.el: Same overall set of changes as ox-deck.
(org-s5-divs): New option, similar usage to `org-html-divs'.
(org-s5-footer-template): Delete.
(org-s5-header-template): Delete.
-rw-r--r-- | contrib/lisp/ox-deck.el | 125 | ||||
-rw-r--r-- | contrib/lisp/ox-s5.el | 178 | ||||
-rw-r--r-- | lisp/ox-html.el | 35 |
3 files changed, 195 insertions, 143 deletions
diff --git a/contrib/lisp/ox-deck.el b/contrib/lisp/ox-deck.el index 27d4f90..d6cdd1c 100644 --- a/contrib/lisp/ox-deck.el +++ b/contrib/lisp/ox-deck.el @@ -53,8 +53,8 @@ :options-alist ((:html-link-home "HTML_LINK_HOME" nil nil) (:html-link-up "HTML_LINK_UP" nil nil) - (:html-postamble nil "html-postamble" nil t) - (:html-preamble nil "html-preamble" nil t) + (:deck-postamble "DECK_POSTAMBLE" nil org-deck-postamble newline) + (:deck-preamble "DECK_PREAMBLE" nil org-deck-preamble newline) (:html-head-include-default-style "HTML_INCLUDE_DEFAULT_STYLE" nil nil) (:html-head-include-scripts "HTML_INCLUDE_SCRIPTS" nil nil) (:deck-base-url "DECK_BASE_URL" nil org-deck-base-url) @@ -166,37 +166,61 @@ Can be overriden with the DECK_BASE_URL property." :group 'org-export-deck :type 'string) -(defcustom org-deck-postamble-template - "<h1>%author - %title</h1>" - "Format template to specify the postamble section of document. -Completed using `org-fill-template', optional keys include -%author, %email, %file, %title and %date. +(defvar org-deck-pre/postamble-styles + `((both "left: 5px; width: 100%;") + (preamble "position: absolute; top: 10px;") + (postamble "")) + "Alist of css styles for the preamble, postamble and both respectively. +Can be overriden in `org-deck-styles'. See also `org-html-divs'.") + +(defcustom org-deck-postamble "<h1>%a - %t</h1>" + "Non-nil means insert a postamble in HTML export. + +When set to a string, use this string +as the postamble. When t, insert a string as defined by the +formatting string in `org-html-postamble-format'. + +When set to a function, apply this function and insert the +returned string. The function takes the property list of export +options as its only argument. This is included in the document at the bottom of the content section, and uses the postamble element and id from `org-html-divs'. The default places the author and presentation -title at the bottom of each slide. See also -`org-deck-preamble-postamble-styles'." - :group 'org-export-deck - :type 'string) +title at the bottom of each slide. -(defcustom org-deck-preamble-template "" - "Format template to specify the preamble section of the document. -Completed using `org-fill-template', optional keys include -%author, %email, %file, %title and %date. +The css styling is controlled by `org-deck-pre/postamble-styles'. -This is included before the content section of the document and -would normally be a header for the presentation. See also -`org-deck-preamble-postamble-styles'." +Setting :deck-postamble in publishing projects will take +precedence over this variable." :group 'org-export-deck - :type 'string) + :type '(choice (const :tag "No postamble" nil) + (const :tag "Default formatting string" t) + (string :tag "Custom formatting string") + (function :tag "Function (must return a string)"))) -(defvar org-deck-preamble-postamble-styles - `((both "left: 5px; width: 100%;") - (preamble "position: absolute; top: 10px;") - (postamble "")) - "Alist of css styles for the preamble, postamble and both respectively. -Can be overriden in `org-deck-styles'. See also `org-html-divs'.") +(defcustom org-deck-preamble nil + "Non-nil means insert a preamble in HTML export. + +When set to a string, use this string +as the preamble. When t, insert a string as defined by the +formatting string in `org-html-preamble-format'. + +When set to a function, apply this function and insert the +returned string. The function takes the property list of export +options as its only argument. + +This is included in the document at the top of content section, and +uses the preamble element and id from `org-html-divs'. The css +styling is controlled by `org-deck-pre/postamble-styles'. + +Setting :deck-preamble in publishing projects will take +precedence over this variable." + :group 'org-export-deck + :type '(choice (const :tag "No preamble" nil) + (const :tag "Default formatting string" t) + (string :tag "Custom formatting string") + (function :tag "Function (must return a string)"))) (defvar org-deck-toc-styles (mapconcat @@ -207,7 +231,7 @@ Can be overriden in `org-deck-styles'. See also `org-html-divs'.") "#table-of-contents li {padding: 0;}") "\n") "Default css styles used for formatting a table of contents slide. Can be overriden in `org-deck-styles'. -Note that when the headline numbering option is true, a \"list-style: none\" +Note that when the headline numbering option is true, a \"list-style: none\" is automatically added to avoid both numbers and bullets on the toc entries.") (defcustom org-deck-styles @@ -233,13 +257,13 @@ Defaults to styles for the title page." :type 'string) (defcustom org-deck-title-slide-template - "<h1>%title</h1> -<h2>%author</h2> -<h2>%email</h2> -<h2>%date</h2>" + "<h1>%t</h1> +<h2>%a</h2> +<h2>%e</h2> +<h2>%d</h2>" "Format template to specify title page section. -Completed using `org-fill-template', optional keys include -%author, %email, %file, %title and %date. +See `org-html-postamble-format' for the valid elements which +can be included. It will be wrapped in the element defined in the :html-container property, and defaults to the value of `org-html-container-element', @@ -349,19 +373,15 @@ the \"slide\" class will be added to the to the list element, (replace-regexp-in-string "^<li>" "<li class='slide'>" text) text))) -(defun org-deck-template-alist (info) - (list - `("title" . ,(car (plist-get info :title))) - `("author" . ,(car (plist-get info :author))) - `("email" . ,(plist-get info :email)) - `("date" . ,(nth 0 (plist-get info :date))) - `("file" . ,(plist-get info :input-file)))) - (defun org-deck-template (contents info) "Return complete document string after HTML conversion. CONTENTS is the transcoded contents string. INFO is a plist holding export options." - (let ((pkg-info (org-deck--get-packages info))) + (let ((pkg-info (org-deck--get-packages info)) + (org-html--pre/postamble-class "deck-status") + (info (plist-put + (plist-put info :html-preamble (plist-get info :deck-preamble)) + :html-postamble (plist-get info :deck-postamble)))) (mapconcat 'identity (list @@ -401,31 +421,25 @@ holding export options." (format "#%s, #%s {%s}" (nth 2 (assq 'preamble org-html-divs)) (nth 2 (assq 'postamble org-html-divs)) - (nth 1 (assq 'both org-deck-preamble-postamble-styles))) + (nth 1 (assq 'both org-deck-pre/postamble-styles))) (format "#%s {%s}" (nth 2 (assq 'preamble org-html-divs)) - (nth 1 (assq 'preamble org-deck-preamble-postamble-styles))) + (nth 1 (assq 'preamble org-deck-pre/postamble-styles))) (format "#%s {%s}" (nth 2 (assq 'postamble org-html-divs)) - (nth 1 (assq 'postamble org-deck-preamble-postamble-styles))) + (nth 1 (assq 'postamble org-deck-pre/postamble-styles))) org-deck-styles "</style>" "</head>" "<body>" - (format "<%s id='%s' class='deck-status'>" - (nth 1 (assq 'preamble org-html-divs)) - (nth 2 (assq 'preamble org-html-divs))) - (org-fill-template - org-deck-preamble-template (org-deck-template-alist info)) - (format "</%s>" (nth 1 (assq 'preamble org-html-divs))) (format "<%s id='%s' class='deck-container'>" (nth 1 (assq 'content org-html-divs)) (nth 2 (assq 'content org-html-divs))) + (org-html--build-pre/postamble 'preamble info) ;; title page (format "<%s id='title-slide' class='slide'>" (plist-get info :html-container)) - (org-fill-template - org-deck-title-slide-template (org-deck-template-alist info)) + (format-spec org-deck-title-slide-template (org-html-format-spec info)) (format "</%s>" (plist-get info :html-container)) ;; toc page (let ((depth (plist-get info :with-toc))) @@ -436,12 +450,7 @@ holding export options." (with-temp-buffer (insert-file-contents snippet) (buffer-string))) (plist-get pkg-info :snippets) "\n") - (format "<%s id='%s' class='deck-status'>" - (nth 1 (assq 'postamble org-html-divs)) - (nth 2 (assq 'postamble org-html-divs))) - (org-fill-template - org-deck-postamble-template (org-deck-template-alist info)) - (format "</%s>" (nth 1 (assq 'postamble org-html-divs))) + (org-html--build-pre/postamble 'postamble info) (format "</%s>" (nth 1 (assq 'content org-html-divs))) "</body>" "</html>\n") "\n"))) diff --git a/contrib/lisp/ox-s5.el b/contrib/lisp/ox-s5.el index eb51686..76f5fa6 100644 --- a/contrib/lisp/ox-s5.el +++ b/contrib/lisp/ox-s5.el @@ -62,15 +62,16 @@ :options-alist ((:html-link-home "HTML_LINK_HOME" nil nil) (:html-link-up "HTML_LINK_UP" nil nil) - (:html-postamble nil "html-postamble" nil t) - (:html-preamble nil "html-preamble" nil t) + (:s5-postamble "S5_POSTAMBLE" nil org-s5-postamble newline) + (:s5-preamble "S5_PREAMBLE" nil org-s5-preamble newline) (:html-head-include-default-style "HTML_INCLUDE_DEFAULT_STYLE" nil nil) (:html-head-include-scripts "HTML_INCLUDE_SCRIPTS" nil nil) (:s5-version "S5_VERSION" nil org-s5-version) (:s5-theme-file "S5_THEME_FILE" nil org-s5-theme-file) (:s5-ui-url "S5_UI_URL" nil org-s5-ui-url) (:s5-default-view "S5_DEFAULT_VIEW" nil org-s5-default-view) - (:s5-control-visibility "S5_CONTROL_VISIBILITY" nil org-s5-control-visibility)) + (:s5-control-visibility "S5_CONTROL_VISIBILITY" nil + org-s5-control-visibility)) :translate-alist ((headline . org-s5-headline) (plain-list . org-s5-plain-list) @@ -117,33 +118,77 @@ Can be overriden with the S5_UI_URL property." :group 'org-export-s5 :type '(choice (const hidden) (const visibile))) -(defcustom org-s5-footer-template - "<h1>%author - %title</h1>" - "Format template to specify footer div. -Completed using `org-fill-template', optional keys include -%author, %email, %file, %title and %date. - -It will be wrapped in a <div> with the id \"footer\"" +(defcustom org-s5-divs + '((preamble "div" "header") + (content "div" "content") + (postamble "div" "footer")) + "Alist of the threed section elements for HTML export. +The car of each entry is one of 'preamble, 'content or 'postamble. +The cdrs of each entry are the ELEMENT_TYPE and ID for each +section of the exported document. + +Note that changing the defaults for the preamble and postamble +will break the standard S5 stylesheets. To generate XOXO compatible +slideshows, change the content ELEMENT_TYPE to \"ul\" or \"ol\" +and the `org-html-container-element' to \"li\"." + :group 'org-export-html + :version "24.4" + :package-version '(Org . "8.0") + :type '(list :greedy t + (list :tag "Preamble" + (const :format "" preamble) + (string :tag "element") (string :tag " id")) + (list :tag "Content" + (const :format "" content) + (string :tag "element") (string :tag " id")) + (list :tag "Postamble" (const :format "" postamble) + (string :tag " id") (string :tag "element")))) + +(defcustom org-s5-postamble "<h1>%a - %t</h1>" + "Preamble inserted into the S5 layout section. +When set to a string, use this string as the postamble. + +When set to a function, apply this function and insert the +returned string. The function takes the property list of export +options as its only argument. + +Setting the S5_POSTAMBLE option -- or the :s5-postamble in publishing +projects -- will take precedence over this variable. + +Note that the default css styling will break if this is set to nil +or an empty string." :group 'org-export-s5 - :type 'string) + :type '(choice (const :tag "No postamble" " ") + (string :tag "Custom formatting string") + (function :tag "Function (must return a string)"))) + +(defcustom org-s5-preamble " " + "Peamble inserted into the S5 layout section. + +When set to a string, use this string as the preamble. + +When set to a function, apply this function and insert the +returned string. The function takes the property list of export +options as its only argument. -(defcustom org-s5-header-template "" - "Format template to specify header div. -Completed using `org-fill-template', optional keys include -%author, %email, %file, %title and %date. +Setting S5_PREAMBLE option -- or the :s5-preamble in publishing +projects -- will take precedence over this variable. -It will be wrapped in a <div> with the id \"header\"" +Note that the default css styling will break if this is set to nil +or an empty string." :group 'org-export-s5 - :type 'string) + :type '(choice (const :tag "No preamble" " ") + (string :tag "Custom formatting string") + (function :tag "Function (must return a string)"))) (defcustom org-s5-title-slide-template - "<h1>%title</h1> -<h2>%author</h2> -<h2>%email</h2> -<h2>%date</h2>" + "<h1>%t</h1> +<h2>%a</h2> +<h2>%e</h2> +<h2>%d</h2>" "Format template to specify title page section. -Completed using `org-fill-template', optional keys include -%author, %email, %file, %title and %date. +See `org-html-postamble-format' for the valid elements which +can be included. It will be wrapped in the element defined in the :html-container property, and defaults to the value of `org-html-container-element', @@ -251,14 +296,6 @@ which will make the list into a \"build\"." " incremental" "")) contents (org-html-end-plain-list type)))) -(defun org-s5-template-alist (info) - `( - ("title" . ,(car (plist-get info :title))) - ("author" . ,(car (plist-get info :author))) - ("email" . ,(plist-get info :email)) - ("date" . ,(nth 0 (plist-get info :date))) - ("file" . ,(plist-get info :input-file)))) - (defun org-s5-inner-template (contents info) "Return body of document string after HTML conversion. CONTENTS is the transcoded contents string. INFO is a plist @@ -269,47 +306,44 @@ holding export options." "Return complete document string after HTML conversion. CONTENTS is the transcoded contents string. INFO is a plist holding export options." - (mapconcat - 'identity - (list - (plist-get info :html-doctype) - (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">" - (plist-get info :language) (plist-get info :language)) - "<head>" - (org-s5--build-meta-info info) - (org-s5--build-head info) - (org-html--build-head info) - (org-html--build-mathjax-config info) - "</head>" - "<body>" - "<div class=\"layout\">" - "<div id=\"controls\"><!-- no edit --></div>" - "<div id=\"currentSlide\"><!-- no edit --></div>" - "<div id='header'>" - (org-fill-template - org-s5-header-template (org-s5-template-alist info)) - "</div>" - "<div id='footer'>" - (org-fill-template - org-s5-footer-template (org-s5-template-alist info)) - "</div>" - "</div>" - (format "<%s id=\"%s\" class=\"presentation\">" - (nth 1 (assq 'content org-html-divs)) - (nth 2 (assq 'content org-html-divs))) - ;; title page - (format "<%s id='title-slide' class='slide'>" - (plist-get info :html-container)) - (org-fill-template - org-s5-title-slide-template (org-s5-template-alist info)) - (format "</%s>" (plist-get info :html-container)) - ;; table of contents. - (let ((depth (plist-get info :with-toc))) - (when depth (org-s5-toc depth info))) - contents - (format "</%s>" (nth 1 (assq 'content org-html-divs))) - "</body>" - "</html>\n") "\n")) + (let ((org-html-divs org-s5-divs) + (info (plist-put + (plist-put info :html-preamble (plist-get info :s5-preamble)) + :html-postamble (plist-get info :s5-postamble)))) + (mapconcat + 'identity + (list + (plist-get info :html-doctype) + (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">" + (plist-get info :language) (plist-get info :language)) + "<head>" + (org-s5--build-meta-info info) + (org-s5--build-head info) + (org-html--build-head info) + (org-html--build-mathjax-config info) + "</head>" + "<body>" + "<div class=\"layout\">" + "<div id=\"controls\"><!-- no edit --></div>" + "<div id=\"currentSlide\"><!-- no edit --></div>" + (org-html--build-pre/postamble 'preamble info) + (org-html--build-pre/postamble 'postamble info) + "</div>" + (format "<%s id=\"%s\" class=\"presentation\">" + (nth 1 (assq 'content org-s5-divs)) + (nth 2 (assq 'content org-s5-divs))) + ;; title page + (format "<%s id='title-slide' class='slide'>" + (plist-get info :html-container)) + (format-spec org-s5-title-slide-template (org-html-format-spec info)) + (format "</%s>" (plist-get info :html-container)) + ;; table of contents. + (let ((depth (plist-get info :with-toc))) + (when depth (org-s5-toc depth info))) + contents + (format "</%s>" (nth 1 (assq 'content org-s5-divs))) + "</body>" + "</html>\n") "\n"))) (defun org-s5-export-as-html (&optional async subtreep visible-only body-only ext-plist) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 7af1a60..457fb44 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -140,6 +140,9 @@ "FORMAT used by `format-time-string' for timestamps in preamble, postamble and metadata.") +(defvar org-html--pre/postamble-class "status" + "CSS class used for pre/postamble") + (defconst org-html-special-string-regexps '(("\\\\-" . "­") ; shy ("---\\([^-]\\)" . "—\\1") ; mdash @@ -1487,22 +1490,27 @@ INFO is a plist used as a communication channel." ;; Return the modified template. (org-element-normalize-string template)))) +(defun org-html-format-spec (info) + "Return format specification for elements that can be +used in the preamble or postamble." + `((?t . ,(org-export-data (plist-get info :title) info)) + (?d . ,(org-export-data (plist-get info :date) info)) + (?T . ,(format-time-string org-html--timestamp-format)) + (?a . ,(org-export-data (plist-get info :author) info)) + (?e . ,(mapconcat + (lambda (e) + (format "<a href=\"mailto:%s\">%s</a>" e e)) + (split-string (plist-get info :email) ",+ *") + ", ")) + (?c . ,(plist-get info :creator)) + (?v . ,(or org-html-validation-link "")))) + (defun org-html--build-pre/postamble (type info) "Return document preamble or postamble as a string, or nil. TYPE is either 'preamble or 'postamble, INFO is a plist used as a communication channel." (let ((section (plist-get info (intern (format ":html-%s" type)))) - (spec `((?t . ,(org-export-data (plist-get info :title) info)) - (?d . ,(org-export-data (plist-get info :date) info)) - (?T . ,(format-time-string org-html--timestamp-format)) - (?a . ,(org-export-data (plist-get info :author) info)) - (?e . ,(mapconcat - (lambda (e) - (format "<a href=\"mailto:%s\">%s</a>" e e)) - (split-string (plist-get info :email) ",+ *") - ", ")) - (?c . ,(plist-get info :creator)) - (?v . ,(or org-html-validation-link ""))))) + (spec (org-html-format-spec info))) (when section (let ((section-contents (if (functionp section) (funcall section info) @@ -1554,9 +1562,10 @@ communication channel." spec)))))) (when (org-string-nw-p section-contents) (concat - (format "<%s id=\"%s\">\n" + (format "<%s id=\"%s\" class=\"%s\">\n" (nth 1 (assq type org-html-divs)) - (nth 2 (assq type org-html-divs))) + (nth 2 (assq type org-html-divs)) + org-html--pre/postamble-class) (org-element-normalize-string section-contents) (format "</%s>\n" (nth 1 (assq type org-html-divs))))))))) |