From 9642179c18c9b137f289410003ad4bdfc77e7e23 Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Tue, 1 Feb 2022 12:02:01 +0100 Subject: [PATCH 1/2] Move extra scripts before initialize --- ox-reveal.el | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ox-reveal.el b/ox-reveal.el index d2de629..07c5df8 100644 --- a/ox-reveal.el +++ b/ox-reveal.el @@ -769,6 +769,17 @@ custom variable `org-reveal-root'." ;; plugin headings (if-format "%s\n" (car reveal-4-plugin)) + ;; Extra tags + (let ((src-list (let ((l (plist-get info :reveal-extra-script-src))) + ;; map to a single string to a list. + (if (stringp l) + (list l) + l)))) + (and src-list + (mapconcat (lambda (src) (format "" src)) + src-list + "\n"))) + ;; Reveal.initialize (let ((reveal-4-plugin-statement (cdr reveal-4-plugin)) (init-options (plist-get info :reveal-init-options)) @@ -818,17 +829,7 @@ Reveal.initialize({ legacy-dependency-statement)) ",\n") ;; Extra initialization scripts - (or (plist-get info :reveal-extra-script) ""))) - ;; Extra tags - (let ((src-list (let ((l (plist-get info :reveal-extra-script-src))) - ;; map to a single string to a list. - (if (stringp l) - (list l) - l)))) - (and src-list - (mapconcat (lambda (src) (format "" src)) - src-list - "\n")))))) + (or (plist-get info :reveal-extra-script) "")))))) (defun org-reveal--read-sexps-from-string (s) (let ((s (string-trim s))) From d9b883ebdf31e22c4349fb47aee581ad5b3e0d0e Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Tue, 1 Feb 2022 16:46:52 +0100 Subject: [PATCH 2/2] Allow extra scripts before and after initialize() --- ox-reveal.el | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/ox-reveal.el b/ox-reveal.el index 07c5df8..c3d4ce1 100644 --- a/ox-reveal.el +++ b/ox-reveal.el @@ -101,6 +101,7 @@ (: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-extra-script-before-src "REVEAL_EXTRA_SCRIPT_BEFORE_SRC" nil org-reveal-extra-script-before-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) @@ -321,7 +322,12 @@ Example: :type 'string) (defcustom org-reveal-extra-script-src '() - "Custom script source that will be embedded in a tags - (let ((src-list (let ((l (plist-get info :reveal-extra-script-src))) - ;; map to a single string to a list. - (if (stringp l) - (list l) - l)))) - (and src-list + ;; Extra tags before the call to Reveal.initialize() + (let ((before-src-list (let ((l (plist-get info :reveal-extra-script-before-src))) + ;; map to a single string to a list. + (if (stringp l) + (list l) + l)))) + (and before-src-list (mapconcat (lambda (src) (format "" src)) - src-list + before-src-list "\n"))) + ;; Reveal.initialize (let ((reveal-4-plugin-statement (cdr reveal-4-plugin)) (init-options (plist-get info :reveal-init-options)) @@ -829,7 +836,17 @@ Reveal.initialize({ legacy-dependency-statement)) ",\n") ;; Extra initialization scripts - (or (plist-get info :reveal-extra-script) "")))))) + (or (plist-get info :reveal-extra-script) ""))) + ;; Extra tags + (let ((src-list (let ((l (plist-get info :reveal-extra-script-src))) + ;; map to a single string to a list. + (if (stringp l) + (list l) + l)))) + (and src-list + (mapconcat (lambda (src) (format "" src)) + src-list + "\n")))))) (defun org-reveal--read-sexps-from-string (s) (let ((s (string-trim s)))