mirror of https://github.com/yjwen/org-reveal.git
add preamble/postamble support.
This commit is contained in:
parent
a7269c2007
commit
da8be68719
45
Readme.org
45
Readme.org
|
@ -7,6 +7,9 @@
|
|||
#+REVEAL_THEME: moon
|
||||
#+REVEAL_HLEVEL: 2
|
||||
|
||||
#+REVEAL_PREAMBLE: my-preamble
|
||||
#+REVEAL_POSTAMBLE: <p> This is the postamble. </p>
|
||||
|
||||
* Reveal.js and Org-Reveal
|
||||
|
||||
- *Reveal.js* is a tool for creating good-looking HTML presentations,
|
||||
|
@ -270,6 +273,48 @@ $ git clone https://github.com/yjwen/org-reveal.git
|
|||
installation, set option =REVEAL_MATH_JAX_URL= to the URL pointing
|
||||
to the local MathJax location.
|
||||
|
||||
** Preamble and Postamble
|
||||
|
||||
You can define preamble and postamble contents which will not be
|
||||
shown as slides, but will be exported into the body part of the
|
||||
generated HTML file, at just before and after the slide contents.
|
||||
|
||||
Change preamble and postamble contents globally by setting variable
|
||||
=org-reveal-preamble= and =org-reveal-postamble=.
|
||||
|
||||
Change preamble and postamble contents locally by setting options
|
||||
=REVEAL_PREAMBLE= and =REVEAL_POSTAMBLE=, as illustrated at the
|
||||
heading part of this document.
|
||||
|
||||
*** Generating Pre/Postamble by Emacs-Lisp Functions
|
||||
|
||||
If the contents of pre/postamble is the name of an evaluated
|
||||
Emacs-Lisp funtion, which must accept an argument of Org-mode
|
||||
info and return a string, the returned string will be taken
|
||||
as pre/postamble contents.
|
||||
|
||||
So you can embed the Emacs-Lisp function as an Org-Babel source
|
||||
block and mark it to be evaluated at exporting the document.
|
||||
|
||||
In this document, the =REVEAL_PREAMBLE= option is set to
|
||||
=my-preamble=, now we will define =my-preamble= in an Org-Bable
|
||||
source block, as illustrated below (invisible in the slides).
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :exports results :results silent
|
||||
(defun my-preamble (info)
|
||||
""
|
||||
"<p>
|
||||
Thanks to Org-Babel, now we can embed preambles into Org document!
|
||||
</p>")
|
||||
|
||||
#+END_SRC
|
||||
|
||||
The =:exports results :result silent= options mark the source
|
||||
block to be evaluated at exporting and the evaluation result
|
||||
is omitted, so it won't disturb slide contents.
|
||||
|
||||
Check the generated HTML to see how it works.
|
||||
|
||||
* Tips
|
||||
|
||||
** Disable Heading Numbers
|
||||
|
|
32
ox-reveal.el
32
ox-reveal.el
|
@ -54,6 +54,8 @@
|
|||
(:reveal-hlevel "REVEAL_HLEVEL" nil nil t)
|
||||
(:reveal-mathjax nil "reveal_mathjax" org-reveal-mathjax t)
|
||||
(:reveal-mathjax-url "REVEAL_MATHJAX_URL" nil org-reveal-mathjax-url t)
|
||||
(:reveal-preamble "REVEAL_PREAMBLE" nil org-reveal-preamble t)
|
||||
(:reveal-postamble "REVEAL_POSTAMBLE" nil org-reveal-postamble t)
|
||||
)
|
||||
|
||||
:translate-alist
|
||||
|
@ -162,6 +164,17 @@ can be include."
|
|||
:group 'org-export-reveal
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-reveal-preamble nil
|
||||
"Preamble contents."
|
||||
:group 'org-export-reveal
|
||||
:type 'string)
|
||||
|
||||
(defcustom org-reveal-postamble nil
|
||||
"Postamble contents."
|
||||
:group 'org-export-reveal
|
||||
:type 'string)
|
||||
|
||||
|
||||
(defun if-format (fmt val)
|
||||
(if val (format fmt val) ""))
|
||||
|
||||
|
@ -517,6 +530,19 @@ the plist used as a communication channel."
|
|||
(org-export-read-attribute :attr_reveal paragraph :frag))
|
||||
contents)))))
|
||||
|
||||
(defun org-reveal--build-pre/postamble (type info)
|
||||
"Return document preamble or postamble as a string, or nil."
|
||||
(let ((section (plist-get info (intern (format ":reveal-%s" type))))
|
||||
(spec (org-html-format-spec info)))
|
||||
(when section
|
||||
(let ((section-contents
|
||||
(if (functionp (intern section)) (funcall (intern section) info)
|
||||
;; else section is a string.
|
||||
(format-spec section spec))))
|
||||
(when (org-string-nw-p section-contents)
|
||||
(org-element-normalize-string section-contents))))))
|
||||
|
||||
|
||||
(defun org-reveal-section (section contents info)
|
||||
"Transcode a SECTION element from Org to HTML.
|
||||
CONTENTS holds the contents of the section. INFO is a plist
|
||||
|
@ -540,8 +566,9 @@ info is a plist holding export options."
|
|||
(org-reveal-stylesheets info)
|
||||
(org-reveal-mathjax-scripts info)
|
||||
"</head>
|
||||
<body>
|
||||
<div class=\"reveal\">
|
||||
<body>\n"
|
||||
(org-reveal--build-pre/postamble 'preamble info)
|
||||
"<div class=\"reveal\">
|
||||
<div class=\"slides\">
|
||||
<section>
|
||||
"
|
||||
|
@ -550,6 +577,7 @@ info is a plist holding export options."
|
|||
contents
|
||||
"</div>
|
||||
</div>\n"
|
||||
(org-reveal--build-pre/postamble 'postamble info)
|
||||
(org-reveal-scripts info)
|
||||
"</body>
|
||||
</html>\n"))
|
||||
|
|
Loading…
Reference in New Issue