add global header/footer support

This commit is contained in:
Stephanus Volke 2016-11-22 07:32:43 +01:00
parent 8f7cf6c308
commit 9e8668c45b
2 changed files with 53 additions and 17 deletions

View File

@ -44,7 +44,7 @@
Extract Reveal.js folders from the downloaded zip file.
If you do not wish to download reveal.js yourself and would rather get a copy from a CDN,
If you do not wish to download reveal.js yourself and would rather get a copy from a CDN,
see the section [[Set the location of Reveal.js]]
** Install org-reveal from MELPA
@ -296,7 +296,7 @@
#+END_SRC
*** Title Slide Background Image
To set the title slide's background image, please specify the
following options:
@ -328,15 +328,19 @@
From Reveal.js 3.1.0, slide numbering can have several custom
formats. To choose one format, please set ~reveal_slide_number~ to
its proper string. For example, ~reveal_slide_number:h/v~.
Supported format string can be found in [[https://github.com/hakimel/reveal.js/#slide-number][Reveal.js manual]].
** Slide Header/Footer
Specify Slide header/footer by =#+REVEAL_SLIDE_HEADER:= and
=#+REVEAL_SLIDE_FOOTER:=. The option content will be put into
divisions of class =slide-header= and =slide-footer=, so you can
control their appearance in custom CSS file(see [[Extra Stylesheets]]).
By default header/footer content will only display on content
slides. To show them also on the title and toc slide you can add
~reveal_global_header:t~ and ~reveal_global_footer:t~ to
~#+OPTIONS:~ line.
** Fragmented Contents
@ -348,7 +352,7 @@
Paragraphs can be fragmented.
#+ATTR_REVEAL: :frag roll-in
- Lists can
- Lists can
- be fragmented.
#+ATTR_REVEAL: :frag roll-in
@ -366,7 +370,7 @@
* highlight-blue
* appear
Setting ~:frag t~ will use Reveal.js default fragment style, which
Setting ~:frag t~ will use Reveal.js default fragment style, which
can be overridden by local option ~#+REVEAL_DEFAULT_FRAG_STYLE~ or
global variable ~org-reveal-default-frag-style~.
@ -473,9 +477,9 @@
1. Use your Emacs theme
2. Use highlight.js
To Use your Emacs theme, please make sure ~htmlize.el~ is
installed. Then no more setup is necessary.
installed. Then no more setup is necessary.
Below is an example. Codes are copied from [[http://www.haskell.org/haskellwiki/The_Fibonacci_sequence][Haskell Wiki]].
#+BEGIN_SRC haskell
@ -489,7 +493,7 @@
*** Using highlight.js
You can also use [[https://highlightjs.org][highlight.js]], by adding ~highlight~ to the Reveal.js
plugin list.
plugin list.
#+BEGIN_SRC org
,#+REVEAL_PLUGINS: (highlight)
#+END_SRC
@ -497,7 +501,7 @@
The default highlighting theme is ~zenburn.css~ brought with
Reveal.js. To use other themes, please specify the CSS file name by
~#+REVEAL_HIGHLIGHT_CSS~ or the variable ~org-reveal-highlight-css~.
The "%r" in the given CSS file name will be replaced by Reveal.js'
URL.
@ -663,7 +667,7 @@
Reveal.js scripts will be embedded into the exported HTML file, to make
a portable HTML. Please note that remote images will /not/ be included in the
single file, so presentations with remote images will still require an Internet
connection.
connection.
Attention: This needs locally available reveal.js files!

View File

@ -64,6 +64,8 @@
(:reveal-extra-js "REVEAL_EXTRA_JS" nil org-reveal-extra-js nil)
(:reveal-hlevel "REVEAL_HLEVEL" nil nil t)
(:reveal-title-slide nil "reveal_title_slide" org-reveal-title-slide t)
(:reveal-slide-global-header nil "reveal_global_header" org-reveal-global-header t)
(:reveal-slide-global-footer nil "reveal_global_footer" org-reveal-global-footer 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-position "REVEAL_TITLE_SLIDE_BACKGROUND_POSITION" nil nil t)
@ -296,6 +298,18 @@ content."
:group 'org-export-reveal
:type 'string)
(defcustom org-reveal-global-header nil
"If non nil, slide header defined in org-reveal-slide-header
is displayed also on title and toc slide"
:group 'org-export-reveal
:type 'boolean)
(defcustom org-reveal-global-footer nil
"If non nil, slide footer defined in org-reveal-slide-footer
is displayed also on title and toc slide"
:group 'org-export-reveal
:type 'boolean)
(defcustom org-reveal-slide-footer nil
"HTML content used as Reveal.js slide footer"
:group 'org-export-reveal
@ -540,7 +554,7 @@ using custom variable `org-reveal-root'."
;; Include CSS for highlight.js if necessary
(if (org-reveal--using-highlight.js info)
(format "<link rel=\"stylesheet\" href=\"%s\"/>"
(format "<link rel=\"stylesheet\" href=\"%s\"/>"
(format-spec (plist-get info :reveal-highlight-css)
`((?r . ,(directory-file-name root-path))))))
;; print-pdf
@ -720,9 +734,18 @@ dependencies: [
(defun org-reveal-toc (depth info)
"Build a slide of table of contents."
(let ((toc (org-html-toc depth info)))
(if toc
(format "<section id=\"table-of-contents\">\n%s</section>\n"
(replace-regexp-in-string "<a href=\"#" "<a href=\"#/slide-" toc)))))
(when toc
(let ((toc-slide-with-header (plist-get info :reveal-slide-global-header))
(toc-slide-with-footer (plist-get info :reveal-slide-global-footer)))
(concat "<section id=\"table-of-contents\">\n"
(when toc-slide-with-header
(let ((header (plist-get info :reveal-slide-header)))
(when header (format "<div class=\"slide-header\">%s</div>\n" header))))
(replace-regexp-in-string "<a href=\"#" "<a href=\"#/slide-" toc)
(when toc-slide-with-footer
(let ((footer (plist-get info :reveal-slide-footer)))
(when footer (format "<div class=\"slide-footer\">%s</div>\n" footer))))
"</section>\n")))))
(defun org-reveal-inner-template (contents info)
"Return body of document string after HTML conversion.
@ -1044,7 +1067,9 @@ info is a plist holding export options."
(title-slide-background-size (plist-get info :reveal-title-slide-background-size))
(title-slide-background-position (plist-get info :reveal-title-slide-background-position))
(title-slide-background-repeat (plist-get info :reveal-title-slide-background-repeat))
(title-slide-background-transition (plist-get info :reveal-title-slide-background-transition)))
(title-slide-background-transition (plist-get info :reveal-title-slide-background-transition))
(title-slide-with-header (plist-get info :reveal-slide-global-header))
(title-slide-with-footer (plist-get info :reveal-slide-global-footer)))
(concat "<section id=\"sec-title-slide\""
(when title-slide-background
(concat " data-background=\"" title-slide-background "\""))
@ -1057,10 +1082,17 @@ info is a plist holding export options."
(when title-slide-background-transition
(concat " data-background-transition=\"" title-slide-background-transition "\""))
">"
(when title-slide-with-header
(let ((header (plist-get info :reveal-slide-header)))
(when header (format "<div class=\"slide-header\">%s</div>\n" header))))
(cond ((eq title-slide nil) nil)
((stringp title-slide) (format-spec title-slide (org-html-format-spec info)))
((eq title-slide 'auto) (org-reveal--auto-title-slide-template info)))
"\n</section>\n"))))
"\n"
(when title-slide-with-footer
(let ((footer (plist-get info :reveal-slide-footer)))
(when footer (format "<div class=\"slide-footer\">%s</div>\n" footer))))
"</section>\n"))))
contents
"</div>
</div>\n"