add flipcard feature into ox-reveal

This commit is contained in:
2021-01-23 17:02:33 +01:00
parent 79a9cca457
commit 7921df18ac
5 changed files with 187 additions and 17 deletions

View File

@@ -969,8 +969,54 @@ used as a communication channel."
(use-package ox-reveal
:defer t ;; will be loaded via `org-export-backends' see above inside `org'
:config
;; #+REVEAL_EXTRA_CSS:
(setq org-reveal-extra-css (concat "file://" (expand-file-name user-emacs-directory) "scripts/flipcard/flipcard.css")) ;; multiple files seperated with \n
;; #+REVEAL_POSTAMBLE:
(setq org-reveal-postamble (replace-regexp-in-string "\n" "" (concat "<script>" (org-reveal--read-file (concat (expand-file-name user-emacs-directory) "scripts/flipcard/flipcard.js")) "\n</script>"))) ;; only one line!
(setq org-reveal-root (concat "file://" (expand-file-name user-emacs-directory) "scripts/reveal.js"))
(setq org-reveal-single-file t))
(setq org-reveal-single-file t)
;; overwrite to implement `org-reveal-single-file' (:reveal-single-file)
;; used in `org-reveal-scripts' as reveal-4-plugin
(defun org-reveal-plugin-scripts-4 (info)
"Return scripts for initializing reveal.js 4.x builtin scripts"
(let ((plugins (org-reveal--get-plugins info)))
(if (not (null plugins))
;; Generate plugin scripts
(let* ((available-plugins
'(highlight ("RevealHighlight" . "highlight/highlight.js")
markdown ("RevealMarkdown" . "markdown/markdown.js")
search ("RevealSearch" . "search/search.js")
notes ("RevealNotes" . "notes/notes.js")
math ("RevealMath" . "math/math.js")
zoom ("RevealZoom" . "zoom/zoom.js")))
(plugin-info (seq-filter 'identity
(seq-map (lambda (p)
(plist-get available-plugins p))
plugins))))
(if (not (null plugin-info))
(cons
;; Plugin initialization script
(let* ((root-path (file-name-as-directory (plist-get info :reveal-root))) ;; changed
(local-root-path (org-reveal--file-url-to-path root-path)) ;; changed
(in-single-file (plist-get info :reveal-single-file))) ;; changed
(mapconcat
(lambda (p)
(if in-single-file
(concat "<script>\n"
(org-reveal--read-file
(concat local-root-path "plugin/" (cdr p)))
"\n</script>")
(format "<script src=\"%splugin/%s\"></script>\n" root-path (cdr p))))
plugin-info
""))
;; Reveal initialization for plugins
(format "plugins: [%s]"
(mapconcat #'car plugin-info ",")))
;; No available plugin info found. Perhaps wrong plugin
;; names are given
(cons nil nil)))
;; No plugins, return empty string
(cons nil nil)))))
(use-package org-drill ;; requires persist https://elpa.gnu.org/packages/persist.html
:commands org-drill)