diff --git a/Readme.org b/Readme.org index e104257..ad1b82d 100755 --- a/Readme.org +++ b/Readme.org @@ -14,6 +14,7 @@ #+REVEAL_HLEVEL: 2 #+REVEAL_HEAD_PREAMBLE: #+REVEAL_POSTAMBLE:

Created by yjwen.

+#+REVEAL_PLUGINS: (highlight markdown) * 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= to =nil= and export again. + If codes are not highlighted, please mark sure =htmlize.el= is + installed. + ** MathJax :PROPERTIES: :CUSTOM_ID: my-heading @@ -430,6 +434,21 @@ fibs = 0 : 1 : next fibs ,#+REVEAL_EXTRA_CSS: url-to-custom-stylesheet.css #+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 Set =REVEAL_EXTRA_JS= to the url of extra reveal.js dependent diff --git a/ox-reveal.el b/ox-reveal.el index 27a6d80..3c25e9b 100755 --- a/ox-reveal.el +++ b/ox-reveal.el @@ -66,6 +66,7 @@ (:reveal-preamble "REVEAL_PREAMBLE" nil org-reveal-preamble t) (:reveal-head-preamble "REVEAL_HEAD_PREAMBLE" nil org-reveal-head-preamble t) (:reveal-postamble "REVEAL_POSTAMBLE" nil org-reveal-postamble t) + (:reveal-plugins "REVEAL_PLUGINS" nil org-reveal-plugins t) ) :translate-alist @@ -221,6 +222,11 @@ can be include." :group 'org-export-reveal :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) (if val (format fmt val) "")) @@ -337,50 +343,35 @@ holding contextual information." :tag "Org Export reveal" :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) "Return the HTML contents for declaring reveal stylesheets using custom variable `org-reveal-root'." - (let* ((root-path (plist-get info :reveal-root)) - (css-dir-name (org-reveal--append-path root-path "css")) - (min-css-file-name (org-reveal--append-path css-dir-name "reveal.min.css")) - (theme-file (format "%s.css" (plist-get info :reveal-theme))) - (theme-path (org-reveal--append-path css-dir-name "theme")) - (theme-full (org-reveal--append-path theme-path theme-file)) - (extra-css (plist-get info :reveal-extra-css)) - (extra-css-link-tag (if extra-css - (format "" extra-css) - "")) - (pdf-css (org-reveal--append-pathes css-dir-name '("print" "pdf.css")))) - (format " - -%s + (let ((root-path (file-name-as-directory (plist-get info :reveal-root)))) + (concat + ;; stylesheets + (format " + + +" + root-path root-path + (plist-get info :reveal-theme)) + ;; extra css + (let ((extra-css (plist-get info :reveal-extra-css))) + (if extra-css (format "" extra-css) "")) + ;; print-pdf + (format " " - min-css-file-name theme-full extra-css-link-tag - pdf-css))) + root-path)))) (defun org-reveal-mathjax-scripts (info) "Return the HTML contents for declaring MathJax scripts" @@ -392,90 +383,107 @@ using custom variable `org-reveal-root'." (defun org-reveal-scripts (info) "Return the necessary scripts for initializing reveal.js using custom variable `org-reveal-root'." - (let* ((root-path (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))) + (let* ((root-path (file-name-as-directory (plist-get info :reveal-root)))) (concat - (format "\n\n" - (org-reveal--append-path lib-js-dir-name "head.min.js") - (org-reveal--append-pathes root-path '("js" "reveal.min.js"))) - " + +" + root-path root-path) + ;; plugin headings + " +\n"))) + ;; optional JS library heading + " +// Optional libraries used to extend on reveal.js +dependencies: [ +" + ;; JS libraries + (let ((builtins-code + (let ((builtins + '(classList + (format " { src: '%slib/js/classList.js', condition: function() { return !document.body.classList; } }" root-path) + markdown + (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) + highlight + (format " { src: '%splugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }" root-path) + zoom + (format " { src: '%splugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }" root-path) + notes + (format " { src: '%splugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path) + search + (format " { src: '%splugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }" root-path) + remotes + (format " { src: '%splugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)))) + (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)) + + + " +] +}); +\n"))) (defun org-reveal-toc-headlines-r (headlines info prev_level hlevel prev_x prev_y) "Generate toc headline text recursively."