Merge branch 'master' into stable

This commit is contained in:
yujie 2016-02-25 10:19:05 +08:00
commit c4b6e7c3d6
6 changed files with 139 additions and 64 deletions

0
.gitignore vendored Executable file → Normal file
View File

106
Readme.org Executable file → Normal file
View File

@ -14,9 +14,12 @@
#+REVEAL_HLEVEL: 2
#+REVEAL_HEAD_PREAMBLE: <meta name="description" content="Org-Reveal Introduction.">
#+REVEAL_POSTAMBLE: <p> Created by yjwen. </p>
#+REVEAL_PLUGINS: (highlight markdown notes)
#+REVEAL_PLUGINS: (markdown notes)
#+REVEAL_EXTRA_CSS: ./local.css
[[http://melpa.org/#/ox-reveal][file:http://melpa.org/packages/ox-reveal-badge.svg]]
[[http://www.gnu.org/licenses/gpl-3.0.html][http://img.shields.io/:license-gpl3-blue.svg]]
* Reveal.js and Org-Reveal
- *Reveal.js* is a tool for creating good-looking HTML presentations,
@ -30,47 +33,57 @@
* Requirements and Installation
- Reveal.js.
- Latest org-mode.
- Org-mode.
- ox-reveal.el.
- htmlize.el (optional, for syntax highlighting).
- And, of course, emacs.
** Obtain Reveal.js
** Install Reveal.js
Download Reveal.js packages from [[https://github.com/hakimel/reveal.js/][here]].
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,
see the section /Set the location of Reveal.js/
see the section [[Set the location of Reveal.js]]
** Obtain org-mode
** Install org-reveal from MELPA
*Note*: Org-reveal relies on the Org-mode 8.0 export frame work.
Pre-packaged org-mode may be out-of-date.
The easiest way to install org-reveal is to install package
ox-reveal from MELPA.
If in doubt, use the latest development version from the repository.
#+BEGIN_SRC sh
$ git clone git://orgmode.org/org-mode.git
#+END_SRC
Please refer to [[http://melpa.org/#/getting-started]] for using MELPA.
Follow the [[http://orgmode.org/worg/dev/org-build-system.html][online instruction]] to build and install Org-mode.
*Note*: It is suggested to use the [[http://orgmode.org/elpa.html][Org ELPA]] archive in pair
with the ox-reveal packages. Emacs builtin Org-mode package may be
out of date for MELPA's ox-reveal.
** Obtain Org-reveal
** Install org-reveal from GitHub
Download the latest Org-reveal package from [[https://github.com/yjwen/org-reveal][the Org-reveal GitHub page]].
You can also install the latest developing version of org-reveal directly
from GitHub.
Or clone the GitHub repository:
#+BEGIN_SRC sh
$ git clone https://github.com/yjwen/org-reveal.git
#+END_SRC
Please download the latest Org-reveal package from [[https://github.com/yjwen/org-reveal][the Org-reveal
GitHub page]]. Or clone the GitHub repository:
#+BEGIN_SRC sh
git clone https://github.com/yjwen/org-reveal.git
#+END_SRC
Copy =ox-reveal.el= to the Org-mode installation directory.
Copy =ox-reveal.el= to one of your Emacs's ~load-path~, and add the
following statement to your =.emacs= file.
#+BEGIN_SRC lisp
(require 'ox-reveal)
#+END_SRC
*Note*: It is suggested to use the Org-mode git repository in pair
with the GitHub org-reveal. Please get the Org-mode git repository
by:
#+BEGIN_SRC sh
$ git clone git://orgmode.org/org-mode.git
#+END_SRC
Follow the [[http://orgmode.org/worg/dev/org-build-system.html][online instruction]] for building and installing Org-mode.
Add the following statement to your =.emacs= file.
#+BEGIN_SRC lisp
(require 'ox-reveal)
#+END_SRC
* Configuration
@ -175,7 +188,7 @@ $ git clone https://github.com/yjwen/org-reveal.git
* Setting Org files local HLevel to option =REVEAL_HLEVEL=.
#+BEGIN_SRC org
,#+REVEAL_HLEVEL 2
,#+REVEAL_HLEVEL: 2
#+END_SRC
** Force Split
@ -284,7 +297,18 @@ $ git clone https://github.com/yjwen/org-reveal.git
ratio.
** Slide Numbering
Activate slide numbers by setting =#+REVEAL_SLIDE_NUMBER:= to =t= (true).
By default, a flatten slide number is showed at the lower-right corner of each slide.
To disable slide numbering, please add ~reveal_slide_number:nil~ to
~#+OPTIONS:~ line.
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
@ -421,21 +445,39 @@ $ git clone https://github.com/yjwen/org-reveal.git
=org-reveal-history=, =org-reveal-center=, =org-reveal-rolling-links=, =org-reveal-keyboard=, =org-reveal-overview=
For an example, please refer to the heading part of this document.
** Source Codes
** Highlight Source Code
Org-reveal use Org-Babel to highlight source codes.
There are two ways to highlight source code.
1. Use your Emacs theme
2. Use highlight.js
Codes copied from [[http://www.haskell.org/haskellwiki/The_Fibonacci_sequence][Haskell Wiki]].
#+BEGIN_SRC haskell
To Use your Emacs theme, please make sure ~htmlize.el~ is
installed. Then no more setup is necessary.
fibs = 0 : 1 : next fibs
Below is an example. Codes are copied from [[http://www.haskell.org/haskellwiki/The_Fibonacci_sequence][Haskell Wiki]].
#+BEGIN_SRC haskell
fibs = 0 : 1 : next fibs
where next (a : t@(b:_)) = (a+b) : next t
#+END_SRC
#+END_SRC
If you saw odd indentation, please set variable =org-html-indent=
to =nil= and export again.
If code is not highlighted, please make sure =htmlize.el= is installed.
*** Using highlight.js
You can also use [[http://hightlightjs.org][highlight.js]], by adding ~highlight~ to the Reveal.js
plugin list.
#+BEGIN_SRC org
,#+REVEAL_PLUGINS: (highlight)
#+END_SRC
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.
** MathJax
:PROPERTIES:

0
images/hlevel.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

0
images/hlevel2.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

0
images/whale.jpg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

97
ox-reveal.el Executable file → Normal file
View File

@ -83,18 +83,16 @@
(:reveal-default-frag-style "REVEAL_DEFAULT_FRAG_STYLE" nil org-reveal-default-frag-style t)
(:reveal-single-file nil "reveal_single_file" org-reveal-single-file t)
(:reveal-init-script "REVEAL_INIT_SCRIPT" nil org-reveal-init-script space)
(:reveal-highlight-css "REVEAL_HIGHLIGHT_CSS" nil org-reveal-highlight-css nil)
)
:translate-alist
'((export-block . org-reveal-export-block)
(headline . org-reveal-headline)
'((headline . org-reveal-headline)
(inner-template . org-reveal-inner-template)
(item . org-reveal-item)
(keyword . org-reveal-keyword)
(link . org-reveal-link)
(latex-environment . (lambda (latex-env contents info)
(setq info (plist-put info :reveal-mathjax t))
(org-html-latex-environment latex-env contents info)))
(latex-environment . org-reveal-latex-environment)
(latex-fragment . (lambda (frag contents info)
(setq info (plist-put info :reveal-mathjax t))
(org-html-latex-fragment frag contents info)))
@ -102,10 +100,10 @@
(quote-block . org-reveal-quote-block)
(section . org-reveal-section)
(src-block . org-reveal-src-block)
(special-block . org-reveal-special-block)
(template . org-reveal-template))
:filters-alist '((:filter-parse-tree . org-reveal-filter-parse-tree))
:export-block '("REVEAL" "NOTES")
)
(defcustom org-reveal-root "./reveal.js"
@ -226,10 +224,10 @@ can contain the following escaping elements:
:group 'org-export-reveal
:type 'boolean)
(defcustom org-reveal-slide-number t
(defcustom org-reveal-slide-number "c"
"Reveal showing slide numbers."
:group 'org-export-reveal
:type 'boolean)
:type 'string)
(defcustom org-reveal-keyboard t
"Reveal use keyboard navigation."
@ -333,6 +331,11 @@ content."
:group 'org-export-reveal
:type 'string)
(defcustom org-reveal-highlight-css "%r/lib/css/zenburn.css"
"Hightlight.js CSS file."
:group 'org-export-reveal
:type 'string)
(defcustom org-reveal-note-key-char "n"
"If not nil, org-reveal-note-key-char's value is registered as
the key character to Org-mode's structure completion for
@ -366,16 +369,18 @@ holding contextual information."
(and frag
(format " class=\"%s\"" (frag-style frag info))))
(defun org-reveal-export-block (export-block contents info)
"Transocde a EXPORT-BLOCK element from Org to Reveal.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((block-type (org-element-property :type export-block))
(block-string (org-element-property :value export-block)))
(cond ((string= block-type "NOTES")
(format "<aside class=\"notes\">\n%s\n</aside>\n"
(org-export-string-as block-string 'html 'body-only)))
((string= block-type "HTML")
(org-remove-indentation block-string)))))
(defun org-reveal-special-block (special-block contents info)
"Transcode a SPECIAL-BLOCK element from Org to Reveal.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information.
If the block type is 'NOTES', transcode the block into a
Reveal.js slide note. Otherwise, export the block as by the HTML
exporter."
(let ((block-type (org-element-property :type special-block)))
(if (string= block-type "NOTES")
(format "<aside class=\"notes\">\n%s\n</aside>\n" contents)
(org-html-special-block special-block contents info))))
;; Copied from org-html-headline and modified to embed org-reveal
;; specific attributes.
@ -477,6 +482,11 @@ using custom variable `org-reveal-root'."
(local-theme-css (concat local-root "css/theme/" theme ".css"))
(in-single-file (plist-get info :reveal-single-file)))
(concat
;; Default embedded style sheets
"<style type=\"text/css\">
.underline { text-decoration: underline; }
</style>
"
;; stylesheets
(if (and in-single-file
(file-readable-p local-reveal-css)
@ -500,7 +510,13 @@ using custom variable `org-reveal-root'."
"<link rel=\"stylesheet\" href=\"" theme-css "\" id=\"theme\"/>\n"))
;; extra css
(let ((extra-css (plist-get info :reveal-extra-css)))
(if extra-css (format "<link rel=\"stylesheet\" href=\"%s\"/>" extra-css) ""))
(if (string= extra-css "") ""
(format "<link rel=\"stylesheet\" href=\"%s\"/>\n" extra-css)))
;; Include CSS for highlight.js if necessary
(if (org-reveal--using-highlight.js info)
(format "<link rel=\"stylesheet\" href=\"%s\"/>"
(format-spec (plist-get info :reveal-highlight-css)
`((?r . ,(directory-file-name root-path))))))
;; print-pdf
(if in-single-file ""
(format "
@ -579,7 +595,9 @@ overview: %s,
(if (plist-get info :reveal-progress) "true" "false")
(if (plist-get info :reveal-history) "true" "false")
(if (plist-get info :reveal-center) "true" "false")
(if (plist-get info :reveal-slide-number) "true" "false")
(let ((slide-number (plist-get info :reveal-slide-number)))
(if slide-number (format "'%s'" slide-number)
"false"))
(if (plist-get info :reveal-rolling-links) "true" "false")
(if (plist-get info :reveal-keyboard) "true" "false")
(if (plist-get info :reveal-overview) "true" "false"))
@ -656,11 +674,12 @@ dependencies: [
(mapcar
(lambda (p)
(eval (plist-get builtins p)))
(let ((buffer-plugins (plist-get info :reveal-plugins)))
(cond
((string= buffer-plugins "") ())
(buffer-plugins (car (read-from-string buffer-plugins)))
(t org-reveal-plugins)))))
(let ((buffer-plugins (condition-case e
(car (read-from-string (plist-get info :reveal-plugins)))
(end-of-file nil)
(wrong-type-argument nil))))
(or (and buffer-plugins (listp buffer-plugins) buffer-plugins)
org-reveal-plugins))))
(extra-codes (plist-get info :reveal-extra-js))
(total-codes
(if (string= "" extra-codes) builtin-codes
@ -739,7 +758,7 @@ holding export options."
;; Check-boxes in descriptive lists are associated to tag.
(concat (format "<dt%s>%s</dt>"
attr-html (concat checkbox term))
"<dd>"))))
(format "<dd%s>" attr-html)))))
(unless (eq type 'descriptive) checkbox)
(and contents (org-trim contents))
(case type
@ -833,6 +852,16 @@ the result is the Data URIs of the referenced image."
(replace-regexp-in-string "<a href=\"#" "<a href=\"#/slide-"
(org-html-link link desc info))))))
(defun org-reveal-latex-environment (latex-env contents info)
"Transcode a LaTeX environment from Org to Reveal.
LATEX-ENV is the Org element. CONTENTS is the contents of the environment. INFO is a plist holding contextual information "
(setq info (plist-put info :reveal-mathjax t))
(let ((attrs (org-export-read-attribute :attr_html latex-env)))
(format "<div%s>\n%s\n</div>\n"
(if attrs (concat " " (org-html--make-attribute-string attrs)) "")
(org-html-latex-environment latex-env contents info))))
(defun org-reveal-plain-list (plain-list contents info)
"Transcode a PLAIN-LIST element from Org to Reveal.
@ -871,18 +900,22 @@ holding contextual information."
;; Just return the contents. No "<div>" tags.
contents)
(defun org-reveal--using-highlight.js (info)
"Check whether highlight.js plugin is enabled."
(let ((reveal-plugins (condition-case e
(car (read-from-string (plist-get info :reveal-plugins)))
(end-of-file nil)
(wrong-type-argument nil))))
(memq 'highlight (or (and reveal-plugins (listp reveal-plugins) reveal-plugins)
org-reveal-plugins))))
(defun org-reveal-src-block (src-block contents info)
"Transcode a SRC-BLOCK element from Org to Reveal.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(if (org-export-read-attribute :attr_html src-block :textarea)
(org-html--textarea-block src-block)
(let* ((buffer-plugins (plist-get info :reveal-plugins))
(use-highlight (memq 'highlight
(cond
((string= buffer-plugins "") nil)
(buffer-plugins (car (read-from-string buffer-plugins)))
(t org-reveal-plugins))))
(let* ((use-highlight (org-reveal--using-highlight.js info))
(lang (org-element-property :language src-block))
(caption (org-export-get-caption src-block))
(code (if (not use-highlight)