From 843d036d7bad9dd4980db83124ec31303ecd3fe9 Mon Sep 17 00:00:00 2001 From: Arjen Wiersma Date: Mon, 8 Feb 2021 20:54:38 +0100 Subject: [PATCH] Add REVEAL_EXTRA_SCRIPT to add custom javascript code If you want to add extra code outside of the =Reveal.initialize= block, then =#+REVEAL_EXTRA_SCRIPT= can be used. The code will be inserted after closing the =Reveal.initialize= statement, but before the closing == tag. --- Readme.org | 5 +++++ ox-reveal.el | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Readme.org b/Readme.org index 59ffff7..d518f7b 100644 --- a/Readme.org +++ b/Readme.org @@ -879,6 +879,11 @@ To disable the automatic TOC, add =toc:nil= to =#+OPTIONS= ~#+REVEAL_INIT_SCRIPT~ (multiple statements are concatenated) or by custom variable ~org-reveal-init-script~. + If you want to add extra code outside of the ~Reveal.initialize~ + block, then ~#+REVEAL_EXTRA_SCRIPT~ can be used. The code will be + inserted after closing the ~Reveal.initialize~ statement, but before + the closing ~~ tag. + ** Executable Source Blocks To allow live execution of code in some languages, enable the klipse plugin by setting ~org-reveal-klipsify-src~ to non-nil. Src blocks with the languages ~js~, ~clojure~, ~html~, ~python~, ~ruby~, ~scheme~, ~php~ will be executed with output shown in a console-like environment. See the source code of ~org-reveal-src-block~ for more details. diff --git a/ox-reveal.el b/ox-reveal.el index 83277c9..6537ffd 100644 --- a/ox-reveal.el +++ b/ox-reveal.el @@ -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-init-script "REVEAL_INIT_SCRIPT" nil org-reveal-init-script space) + (:reveal-extra-script "REVEAL_EXTRA_SCRIPT" nil org-reveal-extra-script space) (: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) @@ -302,6 +303,11 @@ BEFORE the plugins that depend on them." :group 'org-export-reveal :type 'string) +(defcustom org-reveal-extra-script nil + "Custom script that will be passed added to the script block, after Reveal.initialize." + :group 'org-export-reveal + :type 'string) + (defcustom org-reveal-highlight-css "%r/lib/css/zenburn.css" "Highlight.js CSS file." :group 'org-export-reveal @@ -802,7 +808,11 @@ dependencies: [ )) (let ((init-script (plist-get info :reveal-init-script))) (if init-script (concat (if in-single-file "" ",") init-script))) - "});\n\n"))) + "});\n" + (let ((extra-script (plist-get info :reveal-extra-script))) + (if extra-script extra-script)) + " +\n\n"))) (defun org-reveal-plugin-scripts-4 (info) "Return scripts for initializing reveal.js 4.x builtin scripts"