mirror of https://github.com/yjwen/org-reveal.git
Configure built-in scripts by lisp list.
This commit is contained in:
parent
40bd73f4ac
commit
2380fd7bc2
19
Readme.org
19
Readme.org
|
@ -14,6 +14,7 @@
|
||||||
#+REVEAL_HLEVEL: 2
|
#+REVEAL_HLEVEL: 2
|
||||||
#+REVEAL_HEAD_PREAMBLE: <meta name="description" content="Org-Reveal Introduction.">
|
#+REVEAL_HEAD_PREAMBLE: <meta name="description" content="Org-Reveal Introduction.">
|
||||||
#+REVEAL_POSTAMBLE: <p> Created by yjwen. </p>
|
#+REVEAL_POSTAMBLE: <p> Created by yjwen. </p>
|
||||||
|
#+REVEAL_PLUGINS: (highlight markdown)
|
||||||
|
|
||||||
* Reveal.js and Org-Reveal
|
* Reveal.js and Org-Reveal
|
||||||
|
|
||||||
|
@ -341,6 +342,9 @@ fibs = 0 : 1 : next fibs
|
||||||
If you saw odd indentation, please set variable =org-html-indent=
|
If you saw odd indentation, please set variable =org-html-indent=
|
||||||
to =nil= and export again.
|
to =nil= and export again.
|
||||||
|
|
||||||
|
If codes are not highlighted, please mark sure =htmlize.el= is
|
||||||
|
installed.
|
||||||
|
|
||||||
** MathJax
|
** MathJax
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: my-heading
|
:CUSTOM_ID: my-heading
|
||||||
|
@ -430,6 +434,21 @@ fibs = 0 : 1 : next fibs
|
||||||
,#+REVEAL_EXTRA_CSS: url-to-custom-stylesheet.css
|
,#+REVEAL_EXTRA_CSS: url-to-custom-stylesheet.css
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
** Select Built-In Scripts
|
||||||
|
|
||||||
|
Set option =REVEAL_PLUGINS= or variable =org-reveal-plugins= to a
|
||||||
|
lisp list to select built-in scripts.
|
||||||
|
|
||||||
|
Available built-in scripts are:
|
||||||
|
classList/markdown/highlight/zoom/notes/search/remotes.
|
||||||
|
|
||||||
|
Default built-ins are: classList/markdown/highlight/zoom/notes.
|
||||||
|
|
||||||
|
The following examples select /markdown/ and /highlight/ only.
|
||||||
|
#+BEGIN_SRC org
|
||||||
|
,#+REVEAL_PLUGINS: (markdown highlight)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** Extra Dependent Script
|
** Extra Dependent Script
|
||||||
|
|
||||||
Set =REVEAL_EXTRA_JS= to the url of extra reveal.js dependent
|
Set =REVEAL_EXTRA_JS= to the url of extra reveal.js dependent
|
||||||
|
|
224
ox-reveal.el
224
ox-reveal.el
|
@ -66,6 +66,7 @@
|
||||||
(:reveal-preamble "REVEAL_PREAMBLE" nil org-reveal-preamble t)
|
(:reveal-preamble "REVEAL_PREAMBLE" nil org-reveal-preamble t)
|
||||||
(:reveal-head-preamble "REVEAL_HEAD_PREAMBLE" nil org-reveal-head-preamble t)
|
(:reveal-head-preamble "REVEAL_HEAD_PREAMBLE" nil org-reveal-head-preamble t)
|
||||||
(:reveal-postamble "REVEAL_POSTAMBLE" nil org-reveal-postamble t)
|
(:reveal-postamble "REVEAL_POSTAMBLE" nil org-reveal-postamble t)
|
||||||
|
(:reveal-plugins "REVEAL_PLUGINS" nil org-reveal-plugins t)
|
||||||
)
|
)
|
||||||
|
|
||||||
:translate-alist
|
:translate-alist
|
||||||
|
@ -221,6 +222,11 @@ can be include."
|
||||||
:group 'org-export-reveal
|
:group 'org-export-reveal
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
|
(defcustom org-reveal-plugins
|
||||||
|
"(classList markdown highlight zoom notes)"
|
||||||
|
"Default builtin plugins"
|
||||||
|
:group 'org-export-reveal
|
||||||
|
:type 'string)
|
||||||
|
|
||||||
(defun if-format (fmt val)
|
(defun if-format (fmt val)
|
||||||
(if val (format fmt val) ""))
|
(if val (format fmt val) ""))
|
||||||
|
@ -337,50 +343,35 @@ holding contextual information."
|
||||||
:tag "Org Export reveal"
|
:tag "Org Export reveal"
|
||||||
:group 'org-export)
|
:group 'org-export)
|
||||||
|
|
||||||
(defun org-reveal--append-path (dir-name path-name)
|
|
||||||
"Append `path-name' to the end of `dir-name' to form a legal path name."
|
|
||||||
(concat (file-name-as-directory dir-name) path-name))
|
|
||||||
|
|
||||||
(defun org-reveal--append-pathes (dir-name pathes)
|
|
||||||
"Append all the path names in `pathes' to the end of `dir-name'
|
|
||||||
to form a legal path name."
|
|
||||||
(if pathes
|
|
||||||
(org-reveal--append-pathes
|
|
||||||
(org-reveal--append-path dir-name (car pathes))
|
|
||||||
(cdr pathes))
|
|
||||||
dir-name))
|
|
||||||
|
|
||||||
|
|
||||||
(defun org-reveal-stylesheets (info)
|
(defun org-reveal-stylesheets (info)
|
||||||
"Return the HTML contents for declaring reveal stylesheets
|
"Return the HTML contents for declaring reveal stylesheets
|
||||||
using custom variable `org-reveal-root'."
|
using custom variable `org-reveal-root'."
|
||||||
(let* ((root-path (plist-get info :reveal-root))
|
(let ((root-path (file-name-as-directory (plist-get info :reveal-root))))
|
||||||
(css-dir-name (org-reveal--append-path root-path "css"))
|
(concat
|
||||||
(min-css-file-name (org-reveal--append-path css-dir-name "reveal.min.css"))
|
;; stylesheets
|
||||||
(theme-file (format "%s.css" (plist-get info :reveal-theme)))
|
(format "
|
||||||
(theme-path (org-reveal--append-path css-dir-name "theme"))
|
<link rel=\"stylesheet\" href=\"%scss/reveal.min.css\"/>
|
||||||
(theme-full (org-reveal--append-path theme-path theme-file))
|
<link rel=\"stylesheet\" href=\"%scss/theme/%s.css\" id=\"theme\"/>
|
||||||
(extra-css (plist-get info :reveal-extra-css))
|
"
|
||||||
(extra-css-link-tag (if extra-css
|
root-path root-path
|
||||||
(format "<link rel=\"stylesheet\" href=\"%s\"/>" extra-css)
|
(plist-get info :reveal-theme))
|
||||||
""))
|
;; extra css
|
||||||
(pdf-css (org-reveal--append-pathes css-dir-name '("print" "pdf.css"))))
|
(let ((extra-css (plist-get info :reveal-extra-css)))
|
||||||
(format "<link rel=\"stylesheet\" href=\"%s\"/>
|
(if extra-css (format "<link rel=\"stylesheet\" href=\"%s\"/>" extra-css) ""))
|
||||||
<link rel=\"stylesheet\" href=\"%s\" id=\"theme\"/>
|
;; print-pdf
|
||||||
%s
|
(format "
|
||||||
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
|
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
|
||||||
<script>
|
<script>
|
||||||
if( window.location.search.match( /print-pdf/gi ) ) {
|
if( window.location.search.match( /print-pdf/gi ) ) {
|
||||||
var link = document.createElement( 'link' );
|
var link = document.createElement( 'link' );
|
||||||
link.rel = 'stylesheet';
|
link.rel = 'stylesheet';
|
||||||
link.type = 'text/css';
|
link.type = 'text/css';
|
||||||
link.href = '%s';
|
link.href = '%scss/print/pdf.css';
|
||||||
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
"
|
"
|
||||||
min-css-file-name theme-full extra-css-link-tag
|
root-path))))
|
||||||
pdf-css)))
|
|
||||||
|
|
||||||
(defun org-reveal-mathjax-scripts (info)
|
(defun org-reveal-mathjax-scripts (info)
|
||||||
"Return the HTML contents for declaring MathJax scripts"
|
"Return the HTML contents for declaring MathJax scripts"
|
||||||
|
@ -392,90 +383,107 @@ using custom variable `org-reveal-root'."
|
||||||
(defun org-reveal-scripts (info)
|
(defun org-reveal-scripts (info)
|
||||||
"Return the necessary scripts for initializing reveal.js using
|
"Return the necessary scripts for initializing reveal.js using
|
||||||
custom variable `org-reveal-root'."
|
custom variable `org-reveal-root'."
|
||||||
(let* ((root-path (plist-get info :reveal-root))
|
(let* ((root-path (file-name-as-directory (plist-get info :reveal-root))))
|
||||||
(root-dir-name (file-name-as-directory root-path))
|
|
||||||
(lib-dir-name (org-reveal--append-path root-path "lib"))
|
|
||||||
(lib-js-dir-name (org-reveal--append-path lib-dir-name "js"))
|
|
||||||
(plugin-dir-name (org-reveal--append-path root-path "plugin"))
|
|
||||||
(markdown-dir-name (org-reveal--append-path plugin-dir-name "markdown"))
|
|
||||||
(extra-js (plist-get info :reveal-extra-js)))
|
|
||||||
(concat
|
(concat
|
||||||
(format "<script src=\"%s\"></script>\n<script src=\"%s\"></script>\n"
|
;; reveal.js/lib/js/head.min.js
|
||||||
(org-reveal--append-path lib-js-dir-name "head.min.js")
|
;; reveal.js/js/reveal.min.js
|
||||||
(org-reveal--append-pathes root-path '("js" "reveal.min.js")))
|
|
||||||
"<script>\n"
|
|
||||||
(format "
|
(format "
|
||||||
// Full list of configuration options available here:
|
<script src=\"%slib/js/head.min.js\"></script>
|
||||||
// https://github.com/hakimel/reveal.js#configuration
|
<script src=\"%sjs/reveal.min.js\"></script>
|
||||||
Reveal.initialize({
|
"
|
||||||
controls: %s,
|
root-path root-path)
|
||||||
progress: %s,
|
;; plugin headings
|
||||||
history: %s,
|
"
|
||||||
center: %s,
|
<script>
|
||||||
slideNumber: %s,
|
// Full list of configuration options available here:
|
||||||
rollingLinks: %s,
|
// https://github.com/hakimel/reveal.js#configuration
|
||||||
keyboard: %s,
|
Reveal.initialize({
|
||||||
overview: %s,
|
"
|
||||||
%s // slide width
|
(format "
|
||||||
%s // slide height
|
controls: %s,
|
||||||
%s // slide margin
|
progress: %s,
|
||||||
%s // slide minimum scaling factor
|
history: %s,
|
||||||
%s // slide maximum scaling factor
|
center: %s,
|
||||||
|
slideNumber: %s,
|
||||||
|
rollingLinks: %s,
|
||||||
|
keyboard: %s,
|
||||||
|
overview: %s,
|
||||||
|
"
|
||||||
|
(if (plist-get info :reveal-control) "true" "false")
|
||||||
|
(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")
|
||||||
|
(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"))
|
||||||
|
|
||||||
|
;; slide width
|
||||||
|
(let ((width (plist-get info :reveal-width)))
|
||||||
|
(if (> width 0) (format "width: %d,\n" width) ""))
|
||||||
|
|
||||||
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
|
;; slide height
|
||||||
transition: Reveal.getQueryHash().transition || '%s', // default/cube/page/concave/zoom/linear/fade/none
|
(let ((height (plist-get info :reveal-height)))
|
||||||
transitionSpeed: '%s',\n"
|
(if (> height 0) (format "height: %d,\n" height) ""))
|
||||||
(if (plist-get info :reveal-control) "true" "false")
|
|
||||||
(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")
|
|
||||||
(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")
|
|
||||||
(let ((width (plist-get info :reveal-width)))
|
|
||||||
(if (> width 0) (format "width: %d," width)
|
|
||||||
""))
|
|
||||||
(let ((height (plist-get info :reveal-height)))
|
|
||||||
(if (> height 0) (format "height: %d," height)
|
|
||||||
""))
|
|
||||||
(let ((margin (string-to-number (plist-get info :reveal-margin))))
|
|
||||||
(if (>= margin 0) (format "margin: %.2f," margin)
|
|
||||||
""))
|
|
||||||
(let ((min-scale (string-to-number (plist-get info :reveal-min-scale))))
|
|
||||||
(if (> min-scale 0) (format "minScale: %.2f," min-scale)
|
|
||||||
""))
|
|
||||||
(let ((max-scale (string-to-number (plist-get info :reveal-max-scale))))
|
|
||||||
(if (> max-scale 0) (format "maxScale: %.2f," max-scale)
|
|
||||||
""))
|
|
||||||
|
|
||||||
|
;; slide margin
|
||||||
|
(let ((margin (string-to-number (plist-get info :reveal-margin))))
|
||||||
|
(if (>= margin 0) (format "margin: %.2f,\n" margin) ""))
|
||||||
|
|
||||||
|
;; slide minimum scaling factor
|
||||||
|
(let ((min-scale (string-to-number (plist-get info :reveal-min-scale))))
|
||||||
|
(if (> min-scale 0) (format "minScale: %.2f,\n" min-scale) ""))
|
||||||
|
|
||||||
|
;; slide maximux scaling factor
|
||||||
|
(let ((max-scale (string-to-number (plist-get info :reveal-max-scale))))
|
||||||
|
(if (> max-scale 0) (format "maxScale: %.2f,\n" max-scale) ""))
|
||||||
|
|
||||||
|
;; thems and transitions
|
||||||
|
(format "
|
||||||
|
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
|
||||||
|
transition: Reveal.getQueryHash().transition || '%s', // default/cube/page/concave/zoom/linear/fade/none
|
||||||
|
transitionSpeed: '%s',\n"
|
||||||
(plist-get info :reveal-trans)
|
(plist-get info :reveal-trans)
|
||||||
(plist-get info :reveal-speed))
|
(plist-get info :reveal-speed))
|
||||||
(format "
|
;; optional JS library heading
|
||||||
// Optional libraries used to extend on reveal.js
|
"
|
||||||
dependencies: [
|
// Optional libraries used to extend on reveal.js
|
||||||
{ src: '%s', condition: function() { return !document.body.classList; } }
|
dependencies: [
|
||||||
,{ src: '%s', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }
|
"
|
||||||
,{ src: '%s', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }
|
;; JS libraries
|
||||||
,{ src: '%s', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
|
(let ((builtins-code
|
||||||
,{ src: '%s', async: true, condition: function() { return !!document.body.classList; } }
|
(let ((builtins
|
||||||
,{ src: '%s', async: true, condition: function() { return !!document.body.classList; } }
|
'(classList
|
||||||
// { src: '%s', async: true, condition: function() { return !!document.body.classList; } }
|
(format " { src: '%slib/js/classList.js', condition: function() { return !document.body.classList; } }" root-path)
|
||||||
// { src: '%s', async: true, condition: function() { return !!document.body.classList; } }
|
markdown
|
||||||
%s
|
(format " { src: '%splugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||||||
]
|
{ src: '%splugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }" root-path root-path)
|
||||||
});\n"
|
highlight
|
||||||
(org-reveal--append-path lib-js-dir-name "classList.js")
|
(format " { src: '%splugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }" root-path)
|
||||||
(org-reveal--append-path markdown-dir-name "showdown.js")
|
zoom
|
||||||
(org-reveal--append-path markdown-dir-name "markdown.js")
|
(format " { src: '%splugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
|
||||||
(org-reveal--append-pathes plugin-dir-name '("highlight" "highlight.js"))
|
notes
|
||||||
(org-reveal--append-pathes plugin-dir-name '("zoom-js" "zoom.js"))
|
(format " { src: '%splugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
|
||||||
(org-reveal--append-pathes plugin-dir-name '("notes" "notes.js"))
|
search
|
||||||
(org-reveal--append-pathes plugin-dir-name '("search" "search.js"))
|
(format " { src: '%splugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
|
||||||
(org-reveal--append-pathes plugin-dir-name '("remotes" "remotes.js"))
|
remotes
|
||||||
(if extra-js (concat "," extra-js) ""))
|
(format " { src: '%splugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path))))
|
||||||
"</script>\n")))
|
(mapconcat
|
||||||
|
(lambda (p)
|
||||||
|
(eval (plist-get builtins p)))
|
||||||
|
(car (read-from-string (plist-get info :reveal-plugins)))
|
||||||
|
",\n")))
|
||||||
|
(extra-js (plist-get info :reveal-extra-js)))
|
||||||
|
(or (and builtins-code extra-js
|
||||||
|
(concat builtins-code ", " extra-js))
|
||||||
|
builtins-code
|
||||||
|
extra-js))
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
]
|
||||||
|
});
|
||||||
|
</script>\n")))
|
||||||
|
|
||||||
(defun org-reveal-toc-headlines-r (headlines info prev_level hlevel prev_x prev_y)
|
(defun org-reveal-toc-headlines-r (headlines info prev_level hlevel prev_x prev_y)
|
||||||
"Generate toc headline text recursively."
|
"Generate toc headline text recursively."
|
||||||
|
|
Loading…
Reference in New Issue