mirror of https://github.com/yjwen/org-reveal.git
Fixed #199: Automatic title slide to honor exporting options.
This commit is contained in:
parent
414ccf1626
commit
2ce8c93512
93
ox-reveal.el
93
ox-reveal.el
|
@ -64,7 +64,6 @@
|
||||||
(:reveal-extra-js "REVEAL_EXTRA_JS" nil org-reveal-extra-js nil)
|
(:reveal-extra-js "REVEAL_EXTRA_JS" nil org-reveal-extra-js nil)
|
||||||
(:reveal-hlevel "REVEAL_HLEVEL" nil nil t)
|
(:reveal-hlevel "REVEAL_HLEVEL" nil nil t)
|
||||||
(:reveal-title-slide nil "reveal_title_slide" org-reveal-title-slide t)
|
(:reveal-title-slide nil "reveal_title_slide" org-reveal-title-slide t)
|
||||||
(:reveal-title-slide-template "REVEAL_TITLE_SLIDE_TEMPLATE" nil org-reveal-title-slide-template space)
|
|
||||||
(:reveal-title-slide-background "REVEAL_TITLE_SLIDE_BACKGROUND" nil nil t)
|
(:reveal-title-slide-background "REVEAL_TITLE_SLIDE_BACKGROUND" nil nil t)
|
||||||
(:reveal-title-slide-background-size "REVEAL_TITLE_SLIDE_BACKGROUND_SIZE" nil nil t)
|
(:reveal-title-slide-background-size "REVEAL_TITLE_SLIDE_BACKGROUND_SIZE" nil nil t)
|
||||||
(:reveal-title-slide-background-repeat "REVEAL_TITLE_SLIDE_BACKGROUND_REPEAT" nil nil t)
|
(:reveal-title-slide-background-repeat "REVEAL_TITLE_SLIDE_BACKGROUND_REPEAT" nil nil t)
|
||||||
|
@ -125,27 +124,22 @@ else get value from custom variable `org-reveal-hlevel'."
|
||||||
(if hlevel-str (string-to-number hlevel-str)
|
(if hlevel-str (string-to-number hlevel-str)
|
||||||
org-reveal-hlevel)))
|
org-reveal-hlevel)))
|
||||||
|
|
||||||
(defcustom org-reveal-title-slide t
|
(defcustom org-reveal-title-slide 'auto
|
||||||
"Include a title slide."
|
"Non-nil means insert a title slide.
|
||||||
:group 'org-export-reveal
|
|
||||||
:type 'boolean)
|
|
||||||
|
|
||||||
(defcustom org-reveal-title-slide-template
|
When set to `auto', an automatic title slide is generated. When
|
||||||
"<h1>%t</h1>
|
set to a string, use this string as a format string for title
|
||||||
<h2>%a</h2>
|
slide, where the following escaping elements are allowed:
|
||||||
<h2>%e</h2>
|
|
||||||
<h2>%d</h2>"
|
|
||||||
"Format template to specify title page slide. The format string
|
|
||||||
can contain the following escaping elements:
|
|
||||||
|
|
||||||
%s stands for the title.
|
%s stands for the title
|
||||||
%a stands for the author's name.
|
%a stands for the author's name.
|
||||||
%e stands for the author's email.
|
%e stands for the author's email.
|
||||||
%d stands for the date.
|
%d stands for the data.
|
||||||
%% stands for a literal %.
|
%% stands for a literal %."
|
||||||
"
|
|
||||||
:group 'org-export-reveal
|
:group 'org-export-reveal
|
||||||
:type 'string)
|
:type '(choice (const :tag "No title slide" nil)
|
||||||
|
(const :tag "Auto title slide" 'auto)
|
||||||
|
(string :tag "Custom title slide")))
|
||||||
|
|
||||||
(defcustom org-reveal-transition
|
(defcustom org-reveal-transition
|
||||||
"default"
|
"default"
|
||||||
|
@ -958,6 +952,35 @@ contextual information."
|
||||||
contents))
|
contents))
|
||||||
|
|
||||||
|
|
||||||
|
(defun org-reveal--auto-title-slide-template (info)
|
||||||
|
"Generate the automatic title slide template."
|
||||||
|
(let* ((spec (org-html-format-spec info))
|
||||||
|
(title (org-export-data (plist-get info :title) info))
|
||||||
|
(author (cdr (assq ?a spec)))
|
||||||
|
(email (cdr (assq ?e spec)))
|
||||||
|
(date (cdr (assq ?d spec))))
|
||||||
|
(message "date=%s" date)
|
||||||
|
(concat
|
||||||
|
(when (and (plist-get info :with-title)
|
||||||
|
(org-string-nw-p title))
|
||||||
|
(concat "<h1 class=\"title\">" title "</h1>"))
|
||||||
|
(when (and (plist-get info :with-author)
|
||||||
|
(org-string-nw-p author))
|
||||||
|
(concat "<h2 class=\"author\">" author "</h2>"))
|
||||||
|
(when (and (plist-get info :with-email)
|
||||||
|
(org-string-nw-p email))
|
||||||
|
(concat "<h2 class=\"email\">" email "</h2>"))
|
||||||
|
(when (and (plist-get info :with-date)
|
||||||
|
(org-string-nw-p date))
|
||||||
|
(concat "<h2 class=\"date\">" date "</h2>"))
|
||||||
|
(when (plist-get info :time-stamp-file)
|
||||||
|
(concat "<p class=\"date\">"
|
||||||
|
(org-html--translate "Created" info)
|
||||||
|
": "
|
||||||
|
(format-time-string
|
||||||
|
(plist-get info :html-metadata-timestamp-format))
|
||||||
|
"</p>")))))
|
||||||
|
|
||||||
(defun org-reveal-template (contents info)
|
(defun org-reveal-template (contents info)
|
||||||
"Return complete document string after HTML conversion.
|
"Return complete document string after HTML conversion.
|
||||||
contents is the transcoded contents string.
|
contents is the transcoded contents string.
|
||||||
|
@ -978,21 +1001,27 @@ info is a plist holding export options."
|
||||||
(org-reveal--build-pre/postamble 'preamble info)
|
(org-reveal--build-pre/postamble 'preamble info)
|
||||||
"<div class=\"reveal\">
|
"<div class=\"reveal\">
|
||||||
<div class=\"slides\">\n"
|
<div class=\"slides\">\n"
|
||||||
(if (and (plist-get info :reveal-title-slide)
|
;; Title slides
|
||||||
(not (plist-get info :reveal-subtree)))
|
(let ((title-slide (plist-get info :reveal-title-slide)))
|
||||||
(concat
|
(when (and title-slide (not (plist-get info :reveal-subtree)))
|
||||||
(format "<section id=\"sec-title-slide\"%s%s%s%s>\n"
|
(let ((title-slide-background (plist-get info :reveal-title-slide-background))
|
||||||
(if-format " data-background=\"%s\""
|
(title-slide-background-size (plist-get info :reveal-title-slide-background-size))
|
||||||
(plist-get info :reveal-title-slide-background))
|
(title-slide-background-repeat (plist-get info :reveal-title-slide-background-repeat))
|
||||||
(if-format " data-background-size=\"%s\""
|
(title-slide-background-transition (plist-get info :reveal-title-slide-background-transition)))
|
||||||
(plist-get info :reveal-title-slide-background-size))
|
(concat "<section id=\"sec-title-slide\""
|
||||||
(if-format " data-background-repeat=\"%s\""
|
(when title-slide-background
|
||||||
(plist-get info :reveal-title-slide-background-repeat))
|
(concat " data-background=\"" title-slide-background "\""))
|
||||||
(if-format " data-background-transition=\"%s\""
|
(when title-slide-background-size
|
||||||
(plist-get info :reveal-title-slide-background-transition)))
|
(concat " data-background-size=\"" title-slide-background-size "\""))
|
||||||
(format-spec (plist-get info :reveal-title-slide-template) (org-html-format-spec info))
|
(when title-slide-background-repeat
|
||||||
"\n</section>\n")
|
(concat " data-background-repeat=\"" title-slide-background-repeat "\""))
|
||||||
"")
|
(when title-slide-background-transition
|
||||||
|
(concat " data-background-transition=\"" title-slide-background-transition "\""))
|
||||||
|
">"
|
||||||
|
(cond ((eq title-slide nil) nil)
|
||||||
|
((stringp title-slide) (format-spec title-slide (org-html-format-spec)))
|
||||||
|
((eq title-slide 'auto) (org-reveal--auto-title-slide-template info)))
|
||||||
|
"\n</section>\n"))))
|
||||||
contents
|
contents
|
||||||
"</div>
|
"</div>
|
||||||
</div>\n"
|
</div>\n"
|
||||||
|
|
Loading…
Reference in New Issue