Fixed #465. Add option for including script source files.

This commit is contained in:
Yujie Wen 2021-11-14 21:07:04 +08:00
parent a78ca48a33
commit 2adca68b2b
2 changed files with 22 additions and 4 deletions

View File

@ -803,15 +803,22 @@ This feature is turned off by default and needs to be switched on with ~org-reve
.html file. Provide your audience with a link to the client file to allow
them to track your presentation on their own device.
** Extra Stylesheets
** Extra Stylesheets and Script Sources
Set =REVEAL_EXTRA_CSS= to a stylesheet file path in order to load extra custom
Set =REVEAL_EXTRA_CSS= to a stylesheet file path to load extra custom
styles after loading a theme.
Set =REVEAL_EXTRA_SCRIPT_SRC` to script file path to load extra
script sources.
#+BEGIN_SRC org
,#+REVEAL_EXTRA_CSS: url-to-custom-stylesheet.css
,#+REVEAL_EXTRA_CSS: url-to-custom-stylesheet.css
,#+REVEAL_EXTRA_SCRIPT_SRC: url-to-custom-script
#+END_SRC
Same setup can be done globally by customize variables
~org-reveal-extra-css~ and ~org-reveal-extra-script-src~.
** Select Built-In Scripts
Set option =REVEAL_PLUGINS= or variable =org-reveal-plugins= to a

View File

@ -100,6 +100,7 @@
(: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-extra-script "REVEAL_EXTRA_SCRIPT" nil org-reveal-extra-script space)
(:reveal-extra-script-src "REVEAL_EXTRA_SCRIPT_SRC" nil org-reveal-extra-script-src split)
(:reveal-init-options "REVEAL_INIT_OPTIONS" nil org-reveal-init-options newline)
(:reveal-highlight-css "REVEAL_HIGHLIGHT_CSS" nil org-reveal-highlight-css nil)
(:reveal-reveal-js-version "REVEAL_REVEAL_JS_VERSION" nil nil t)
@ -319,6 +320,11 @@ Example:
:group 'org-export-reveal
:type 'string)
(defcustom org-reveal-extra-script-src '()
"Custom script source that will be embedded in a <script src> tag."
:group 'org-export-reveal
:type 'list)
(defcustom org-reveal-highlight-css "%r/lib/css/zenburn.css"
"Highlight.js CSS file."
:group 'org-export-reveal
@ -813,7 +819,12 @@ Reveal.initialize({
",\n")
;; Extra initialization scripts
(or (plist-get info :reveal-extra-script) "")))
)))
;; Extra <script src="..."></script> tags
(let ((src-list (plist-get info :reveal-extra-script-src)))
(and src-list
(mapconcat (lambda (src) (format "<script src=\"%s\"></script>" src))
src-list
"\n"))))))
(defun org-reveal--read-sexps-from-string (s)
(let ((s (string-trim s)))