From: Andreas Gerler Date: Thu, 31 Oct 2019 16:19:22 +0000 (+0100) Subject: update ox-reveal X-Git-Url: http://git.bundesbrandschatzamt.de/?a=commitdiff_plain;h=3ddab02e63114c51a5b7c6fe30a87e86ef2f9e45;p=emacsconfig.git update ox-reveal --- diff --git a/elpa/ox-reveal-20161027.926/ox-reveal-autoloads.el b/elpa/ox-reveal-20161027.926/ox-reveal-autoloads.el deleted file mode 100644 index 21c83365..00000000 --- a/elpa/ox-reveal-20161027.926/ox-reveal-autoloads.el +++ /dev/null @@ -1,33 +0,0 @@ -;;; ox-reveal-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - - -;;;### (autoloads nil "ox-reveal" "ox-reveal.el" (0 0 0 0)) -;;; Generated autoloads from ox-reveal.el - -(autoload 'org-reveal-publish-to-reveal "ox-reveal" "\ -Publish an org file to Html. - -FILENAME is the filename of the Org file to be published. PLIST -is the property list for the given project. PUB-DIR is the -publishing directory. - -Return output file name. - -\(fn PLIST FILENAME PUB-DIR)" nil nil) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ox-reveal" '("org-reveal-" "client-multiplex" "frag-" "if-format"))) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; ox-reveal-autoloads.el ends here diff --git a/elpa/ox-reveal-20161027.926/ox-reveal-pkg.el b/elpa/ox-reveal-20161027.926/ox-reveal-pkg.el deleted file mode 100644 index 3aea48f4..00000000 --- a/elpa/ox-reveal-20161027.926/ox-reveal-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "ox-reveal" "20161027.926" "reveal.js Presentation Back-End for Org Export Engine" '((org "20150330")) :commit "001567cc12d50ba07612edd1718b86a12e8c2547" :keywords '("outlines" "hypermedia" "slideshow" "presentation") :authors '(("Yujie Wen ")) :maintainer '("Yujie Wen ")) diff --git a/elpa/ox-reveal-20161027.926/ox-reveal.el b/elpa/ox-reveal-20161027.926/ox-reveal.el deleted file mode 100644 index 19ff6798..00000000 --- a/elpa/ox-reveal-20161027.926/ox-reveal.el +++ /dev/null @@ -1,1192 +0,0 @@ -;;; ox-reveal.el --- reveal.js Presentation Back-End for Org Export Engine - -;; Copyright (C) 2013 Yujie Wen - -;; Author: Yujie Wen -;; Created: 2013-04-27 -;; Version: 1.0 -;; Package-Version: 20161027.926 -;; Package-Requires: ((org "20150330")) -;; Keywords: outlines, hypermedia, slideshow, presentation - -;; This file is not part of GNU Emacs. - -;;; Copyright Notice: - -;; This program is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . - -;; Please see "Readme.org" for detail introductions. - -;; Pull request: Multiplex Support - Stephen Barrett \n%s\n\n" contents) - (org-html-special-block special-block contents info)))) - -;; Copied from org-html-headline and modified to embed org-reveal -;; specific attributes. -(defun org-reveal-headline (headline contents info) - "Transcode a HEADLINE element from Org to HTML. -CONTENTS holds the contents of the headline. INFO is a plist -holding contextual information." - (unless (org-element-property :footnote-section-p headline) - (if (org-export-low-level-p headline info) - ;; This is a deep sub-tree: export it as in ox-html. - (org-html-headline headline contents info) - ;; Standard headline. Export it as a slide - (let* ((level (org-export-get-relative-level headline info)) - (preferred-id (or (org-element-property :CUSTOM_ID headline) - (org-export-get-reference headline info) - (org-element-property :ID headline))) - (hlevel (org-reveal--get-hlevel info)) - (header (plist-get info :reveal-slide-header)) - (header-div (when header (format "
%s
\n" header))) - (footer (plist-get info :reveal-slide-footer)) - (footer-div (when footer (format "
%s
\n" footer))) - (first-sibling (org-export-first-sibling-p headline info)) - (last-sibling (org-export-last-sibling-p headline info)) - (default-slide-background (plist-get info :reveal-default-slide-background)) - (default-slide-background-size (plist-get info :reveal-default-slide-background-size)) - (default-slide-background-position (plist-get info :reveal-default-slide-background-position)) - (default-slide-background-repeat (plist-get info :reveal-default-slide-background-repeat)) - (default-slide-background-transition (plist-get info :reveal-default-slide-background-transition)) - (slide-section-tag (format "
\n" - (org-html--make-attribute-string - `(:id ,(format "slide-%s" preferred-id) - :data-transition ,(org-element-property :REVEAL_DATA_TRANSITION headline) - :data-state ,(org-element-property :REVEAL_DATA_STATE headline) - :data-background ,(or (org-element-property :REVEAL_BACKGROUND headline) - default-slide-background) - :data-background-size ,(or (org-element-property :REVEAL_BACKGROUND_SIZE headline) - default-slide-background-size) - :data-background-position ,(or (org-element-property :REVEAL_BACKGROUND_POSITION headline) - default-slide-background-position) - :data-background-repeat ,(or (org-element-property :REVEAL_BACKGROUND_REPEAT headline) - default-slide-background-repeat) - :data-background-transition ,(or (org-element-property :REVEAL_BACKGROUND_TRANS headline) - default-slide-background-transition))) - (let ((extra-attrs (org-element-property :REVEAL_EXTRA_ATTR headline))) - (if extra-attrs (format " %s" extra-attrs) "")))) - (ret (concat - (if (or (/= level 1) (not first-sibling)) - ;; Not the first heading. Close previou slide. - (concat - ;; Slide footer if any - footer-div - ;; Close previous slide - "
\n" - (if (<= level hlevel) - ;; Close previous vertical slide group. - "\n"))) - (if (<= level hlevel) - ;; Add an extra "
" to group following slides - ;; into vertical slide group. Transition override - ;; attributes are attached at this level, too. - (let ((attrs - (org-html--make-attribute-string - `(:data-transition ,(org-element-property :REVEAL_DATA_TRANSITION headline))))) - (if (string= attrs "") - "
\n" - (format "
\n" attrs)))) - ;; Start a new slide. - (prog1 - slide-section-tag - ;; Cache the current slide's section tag, except the id attr - (setq org-reveal--last-slide-section-tag - (replace-regexp-in-string "id\\s-*=\\s-*[\][\"].*?[\][\"]" - "" slide-section-tag))) - ;; Slide header if any. - header-div - ;; The HTML content of the headline - ;; Strip the
tags, if any - (let ((html (org-html-headline headline contents info))) - (if (string-prefix-p " and the last
tags from html - (concat "<" - (mapconcat 'identity - (butlast (cdr (split-string html "<" t))) - "<")) - ;; Return the HTML content unchanged - html)) - (if (and (= level 1) - (org-export-last-sibling-p headline info)) - ;; Last head 1. Close all slides. - (concat - ;; Slide footer if any - footer-div - "
\n
\n"))))) - ret)))) - -(defgroup org-export-reveal nil - "Options for exporting Orgmode files to reveal.js HTML pressentations." - :tag "Org Export Reveal" - :group 'org-export) - -(defun org-reveal--read-file (file) - "Return the content of file" - (with-temp-buffer - (insert-file-contents-literally file) - (buffer-string))) - -(defun org-reveal--file-url-to-path (url) - "Convert URL that points to local files to file path." - (replace-regexp-in-string - (if (string-equal system-type "windows-nt") "^file:///" "^file://") - "" url)) - -(defun org-reveal--css-label (in-single-file file-name style-id) - "Generate an HTML label for including a CSS file, if - IN-SINGLE-FILE is t, the content of FILE-NAME is embedded, - otherwise, a `' label is generated." - (when (and file-name (not (string= file-name ""))) - (if in-single-file - ;; Single-file - (let ((local-file-name (org-reveal--file-url-to-path file-name))) - (if (file-readable-p local-file-name) - (concat "\n") - ;; But file is not readable. - (error "Cannot read %s" file-name))) - ;; Not in-single-file - (concat "\n")))) - -(defun org-reveal-stylesheets (info) - "Return the HTML contents for declaring reveal stylesheets -using custom variable `org-reveal-root'." - (let* ((root-path (file-name-as-directory (plist-get info :reveal-root))) - (reveal-css (concat root-path "css/reveal.css")) - (theme (plist-get info :reveal-theme)) - (theme-css (concat root-path "css/theme/" theme ".css")) - (extra-css (plist-get info :reveal-extra-css)) - (in-single-file (plist-get info :reveal-single-file))) - (concat - ;; Default embedded style sheets - " -" - ;; stylesheets - (mapconcat (lambda (elem) (org-reveal--css-label in-single-file (car elem) (cdr elem))) - (append (list (cons reveal-css nil) - (cons theme-css "theme")) - (mapcar (lambda (a) (cons a nil)) - (split-string extra-css "\n"))) - "\n") - - ;; Include CSS for highlight.js if necessary - (if (org-reveal--using-highlight.js info) - (format "" - (format-spec (plist-get info :reveal-highlight-css) - `((?r . ,(directory-file-name root-path)))))) - ;; print-pdf - (if in-single-file "" - (format " - - -" - root-path))))) - -(defun org-reveal-mathjax-scripts (info) - "Return the HTML contents for declaring MathJax scripts" - (if (plist-get info :reveal-mathjax) - ;; MathJax enabled. - (format "\n" - (plist-get info :reveal-mathjax-url)))) - -(defun org-reveal-scripts (info) - "Return the necessary scripts for initializing reveal.js using -custom variable `org-reveal-root'." - (let* ((root-path (file-name-as-directory (plist-get info :reveal-root))) - (head-min-js (concat root-path "lib/js/head.min.js")) - (reveal-js (concat root-path "js/reveal.js")) - ;; Local files - (local-root-path (org-reveal--file-url-to-path root-path)) - (local-head-min-js (concat local-root-path "lib/js/head.min.js")) - (local-reveal-js (concat local-root-path "js/reveal.js")) - (in-single-file (plist-get info :reveal-single-file))) - (concat - ;; reveal.js/lib/js/head.min.js - ;; reveal.js/js/reveal.js - (if (and in-single-file - (file-readable-p local-head-min-js) - (file-readable-p local-reveal-js)) - ;; Embed scripts into HTML - (concat "") - ;; Fall-back to extern script links - (if in-single-file - ;; Tried to embed scripts but failed. Print a message about possible errors. - (error (concat "Cannot read " - (mapconcat 'identity - (delq nil (mapcar (lambda (file) (if (not (file-readable-p file)) file)) - (list local-head-min-js local-reveal-js))) - ", ")))) - (concat - "\n" - "\n")) - ;; plugin headings - " -\n"))) - -(defun org-reveal-toc (depth info) - "Build a slide of table of contents." - (let ((toc (org-html-toc depth info))) - (if toc - (format "
\n%s
\n" - (replace-regexp-in-string "\n%s" org-reveal--last-slide-section-tag "")))) - -(defun org-reveal-parse-keyword-value (value) - "According to the value content, return HTML tags to split slides." - (let ((tokens (mapcar - (lambda (x) (split-string x ":")) - (split-string value)))) - (mapconcat - (lambda (x) (apply 'org-reveal-parse-token x)) - tokens - ""))) - -;; Copied from org-html-format-list-item. Overwrite HTML class -;; attribute when there is attr_html attributes. -(defun org-reveal-format-list-item (contents type checkbox attributes info - &optional term-counter-id - headline) - "Format a list item into HTML." - (let ((attr-html (cond (attributes (format " %s" (org-html--make-attribute-string attributes))) - (checkbox (format " class=\"%s\"" (symbol-name checkbox))) - (t ""))) - (checkbox (concat (org-html-checkbox checkbox info) - (and checkbox " "))) - (br (org-html-close-tag "br" nil info))) - (concat - (case type - (ordered - (let* ((counter term-counter-id) - (extra (if counter (format " value=\"%s\"" counter) ""))) - (concat - (format "" attr-html extra) - (when headline (concat headline br))))) - (unordered - (let* ((id term-counter-id) - (extra (if id (format " id=\"%s\"" id) ""))) - (concat - (format "" attr-html extra) - (when headline (concat headline br))))) - (descriptive - (let* ((term term-counter-id)) - (setq term (or term "(no term)")) - ;; Check-boxes in descriptive lists are associated to tag. - (concat (format "%s" - attr-html (concat checkbox term)) - (format "" attr-html))))) - (unless (eq type 'descriptive) checkbox) - (and contents (org-trim contents)) - (case type - (ordered "") - (unordered "") - (descriptive ""))))) - -;; Copied from org-html-item, changed to call -;; org-reveal-format-list-item. -(defun org-reveal-item (item contents info) - "Transcode an ITEM element from Org to Reveal. -CONTENTS holds the contents of the item. INFO is a plist holding -contextual information." - (let* ((plain-list (org-export-get-parent item)) - (type (org-element-property :type plain-list)) - (counter (org-element-property :counter item)) - (attributes (org-export-read-attribute :attr_html item)) - ; (attributes (org-html--make-attribute-string (org-export-read-attribute :attr_html item))) - (checkbox (org-element-property :checkbox item)) - (tag (let ((tag (org-element-property :tag item))) - (and tag (org-export-data tag info))))) - (org-reveal-format-list-item - contents type checkbox attributes info (or tag counter)))) - -(defun org-reveal-keyword (keyword contents info) - "Transcode a KEYWORD element from Org to Reveal, -and may change custom variables as SIDE EFFECT. -CONTENTS is nil. INFO is a plist holding contextual information." - (let ((key (org-element-property :key keyword)) - (value (org-element-property :value keyword))) - (case (intern key) - (REVEAL (org-reveal-parse-keyword-value value)) - (REVEAL_HTML value) - (HTML value)))) -(defun org-reveal-embedded-svg (path) - "Embed the SVG content into Reveal HTML." - (with-temp-buffer - (insert-file-contents-literally path) - (let ((start (re-search-forward "<[ \t\n]*svg[ \t\n]")) - (end (re-search-forward "<[ \t\n]*/svg[ \t\n]*>"))) - (concat "\n%s\n\n" - (if attrs (concat " " (org-html--make-attribute-string attrs)) "") - (org-html-latex-environment latex-env contents info)))) - -(defun org-reveal-plain-list (plain-list contents info) - "Transcode a PLAIN-LIST element from Org to Reveal. - -CONTENTS is the contents of the list. INFO is a plist holding -contextual information. - -Extract and set `attr_html' to plain-list tag attributes." - (let ((tag (case (org-element-property :type plain-list) - (ordered "ol") - (unordered "ul") - (descriptive "dl"))) - (attrs (org-export-read-attribute :attr_html plain-list))) - (format "%s<%s%s>\n%s\n%s" - (if (string= org-html-checkbox-type 'html) "
" "") - tag - (if attrs (concat " " (org-html--make-attribute-string attrs)) "") - contents - tag - (if (string= org-html-checkbox-type 'html) "
" "")))) - -(defun org-reveal--build-pre/postamble (type info) - "Return document preamble or postamble as a string, or nil." - (let ((section (plist-get info (intern (format ":reveal-%s" type)))) - (spec (org-html-format-spec info))) - (when section - (let ((section-contents - (if (functionp (intern section)) (funcall (intern section) info) - ;; else section is a string. - (format-spec section spec)))) - (when (org-string-nw-p section-contents) - (org-element-normalize-string section-contents)))))) - - -(defun org-reveal-section (section contents info) - "Transcode a SECTION element from Org to Reveal. -CONTENTS holds the contents of the section. INFO is a plist -holding contextual information." - ;; Just return the contents. No "
" tags. - contents) - -(defun org-reveal--using-highlight.js (info) - "Check whether highlight.js plugin is enabled." - (let ((reveal-plugins (condition-case e - (car (read-from-string (plist-get info :reveal-plugins))) - (end-of-file nil) - (wrong-type-argument nil)))) - (memq 'highlight (or (and reveal-plugins (listp reveal-plugins) reveal-plugins) - org-reveal-plugins)))) - -(defun org-reveal-src-block (src-block contents info) - "Transcode a SRC-BLOCK element from Org to Reveal. -CONTENTS holds the contents of the item. INFO is a plist holding -contextual information." - (if (org-export-read-attribute :attr_html src-block :textarea) - (org-html--textarea-block src-block) - (let* ((use-highlight (org-reveal--using-highlight.js info)) - (lang (org-element-property :language src-block)) - (caption (org-export-get-caption src-block)) - (code (if (not use-highlight) - (org-html-format-code src-block info) - (cl-letf (((symbol-function 'org-html-htmlize-region-for-paste) - #'buffer-substring)) - (org-html-format-code src-block info)))) - (frag (org-export-read-attribute :attr_reveal src-block :frag)) - (code-attribs (or (org-export-read-attribute - :attr_reveal src-block :code_attribs) "")) - (label (let ((lbl (org-element-property :name src-block))) - (if (not lbl) "" - (format " id=\"%s\"" lbl))))) - (if (not lang) - (format "
\n%s
" - (or (frag-class frag info) " class=\"example\"") - label - code) - (format - "
\n%s%s\n
" - (if (not caption) "" - (format "" - (org-export-data caption info))) - (if use-highlight - (format "\n%s" - (or (frag-class frag info) "") - label lang code-attribs code) - (format "\n
%s
" - (or (frag-class frag info) - (format " class=\"src src-%s\"" lang)) - label code))))))) - -(defun org-reveal-quote-block (quote-block contents info) - "Transcode a QUOTE-BLOCK element from Org to Reveal. -CONTENTS holds the contents of the block INFO is a plist holding -contextual information." - (format "
\n%s
" - (frag-class (org-export-read-attribute :attr_reveal quote-block :frag) info) - contents)) - - -(defun org-reveal--auto-title-slide-template (info) - "Generate the automatic title slide template." - (let* ((spec (org-html-format-spec info)) - (title (org-export-data (plist-get info :title) info)) - (author (cdr (assq ?a spec))) - (email (cdr (assq ?e spec))) - (date (cdr (assq ?d spec)))) - (concat - (when (and (plist-get info :with-title) - (org-string-nw-p title)) - (concat "

" title "

")) - (when (and (plist-get info :with-author) - (org-string-nw-p author)) - (concat "

" author "

")) - (when (and (plist-get info :with-email) - (org-string-nw-p email)) - (concat "

" email "

")) - (when (and (plist-get info :with-date) - (org-string-nw-p date)) - (concat "

" date "

")) - (when (plist-get info :time-stamp-file) - (concat "

" - (org-html--translate "Created" info) - ": " - (format-time-string - (plist-get info :html-metadata-timestamp-format)) - "

"))))) - -(defun org-reveal-template (contents info) - "Return complete document string after HTML conversion. -contents is the transcoded contents string. -info is a plist holding export options." - (concat - (format "\n\n\n" - (if-format " lang=\"%s\"" (plist-get info :language))) - "\n" - (if-format "%s\n" (org-export-data (plist-get info :title) info)) - (if-format "\n" (plist-get info :author)) - (if-format "\n" (plist-get info :description)) - (if-format "\n" (plist-get info :keywords)) - (org-reveal-stylesheets info) - (org-reveal-mathjax-scripts info) - (org-reveal--build-pre/postamble 'head-preamble info) - (org-element-normalize-string (plist-get info :html-head)) - (org-element-normalize-string (plist-get info :html-head-extra)) - " -\n" - (org-reveal--build-pre/postamble 'preamble info) - "
-
\n" - ;; Title slides - (let ((title-slide (plist-get info :reveal-title-slide))) - (when (and title-slide (not (plist-get info :reveal-subtree))) - (let ((title-slide-background (plist-get info :reveal-title-slide-background)) - (title-slide-background-size (plist-get info :reveal-title-slide-background-size)) - (title-slide-background-position (plist-get info :reveal-title-slide-background-position)) - (title-slide-background-repeat (plist-get info :reveal-title-slide-background-repeat)) - (title-slide-background-transition (plist-get info :reveal-title-slide-background-transition))) - (concat "
" - (cond ((eq title-slide nil) nil) - ((stringp title-slide) (format-spec title-slide (org-html-format-spec info))) - ((eq title-slide 'auto) (org-reveal--auto-title-slide-template info))) - "\n
\n")))) - contents - "
-
\n" - (org-reveal--build-pre/postamble 'postamble info) - (org-reveal-scripts info) - " -\n")) - -(defun org-reveal-filter-parse-tree (tree backend info) - "Do filtering before parsing TREE. - -Tree is the parse tree being exported. BACKEND is the export -back-end used. INFO is a plist-used as a communication channel. - -Assuming BACKEND is `reveal'. - -Each `attr_reveal' attribute is mapped to corresponding -`attr_html' attributes." - (let ((default-frag-style (plist-get info :reveal-default-frag-style))) - (org-element-map tree (remq 'item org-element-all-elements) - (lambda (elem) (org-reveal-append-frag elem default-frag-style)))) - ;; Return the updated tree. - tree) - -(defun org-reveal--update-attr-html (elem frag default-style &optional frag-index) - "Update ELEM's attr_html atrribute with reveal's -fragment attributes." - (let ((attr-html (org-element-property :attr_html elem))) - (when (and frag (not (string= frag "none"))) - (push (cond ((string= frag t) - (if default-style (format ":class fragment %s" default-style) - ":class fragment")) - (t (format ":class fragment %s" frag))) - attr-html) - (when frag-index - (push (format ":data-fragment-index %s" frag-index) attr-html))) - (org-element-put-property elem :attr_html attr-html))) - -(defun org-reveal-append-frag (elem default-style) - "Read org-reveal's fragment attribute from ELEM and append -transformed fragment attribute to ELEM's attr_html plist." - (let ((frag (org-export-read-attribute :attr_reveal elem :frag)) - (frag-index (org-export-read-attribute :attr_reveal elem :frag_idx))) - (if frag - (cond ((and (string= (org-element-type elem) 'plain-list) - (char-equal (string-to-char frag) ?\()) - (let* ((frag-list (car (read-from-string frag))) - (frag-list (if default-style - (mapcar (lambda (s) - "Replace t with default-style" - (if (string= s t) default-style - s)) - frag-list) - frag-list)) - (items (org-element-contents elem))) - (if frag-index - (mapcar* 'org-reveal--update-attr-html - items frag-list default-style (car (read-from-string frag-index))) - (let* ((last-frag (car (last frag-list))) - (tail-list (mapcar (lambda (a) last-frag) - (number-sequence (+ (length frag-list) 1) - (length items)))) - (default-style-list - (mapcar (lambda (a) default-style) - (number-sequence 1 (length items))))) - (nconc frag-list tail-list) - (mapcar* 'org-reveal--update-attr-html items frag-list default-style-list))))) - (t (org-reveal--update-attr-html elem frag default-style frag-index))) - elem))) - -(defvar client-multiplex nil - "used to cause generation of client html file for multiplex") - -(defun org-reveal-export-to-html - (&optional async subtreep visible-only body-only ext-plist) - "Export current buffer to a reveal.js HTML file." - (interactive) - (let* ((extension (concat "." org-html-extension)) - (file (org-export-output-file-name extension subtreep)) - (clientfile (org-export-output-file-name (concat "_client" extension) subtreep))) - - ; export filename_client HTML file if multiplexing - (setq client-multiplex nil) - (setq retfile (org-export-to-file 'reveal file - async subtreep visible-only body-only ext-plist)) - - ; export the client HTML file if client-multiplex is set true - ; by previous call to org-export-to-file - (if (eq client-multiplex t) - (org-export-to-file 'reveal clientfile - async subtreep visible-only body-only ext-plist)) - (cond (t retfile)))) - -(defun org-reveal-export-to-html-and-browse - (&optional async subtreep visible-only body-only ext-plist) - "Export current buffer to a reveal.js and browse HTML file." - (interactive) - (browse-url-of-file (expand-file-name (org-reveal-export-to-html async subtreep visible-only body-only ext-plist)))) - -(defun org-reveal-export-current-subtree - (&optional async subtreep visible-only body-only ext-plist) - "Export current subtree to a Reveal.js HTML file." - (interactive) - (org-narrow-to-subtree) - (let ((ret (org-reveal-export-to-html async subtreep visible-only body-only (plist-put ext-plist :reveal-subtree t)))) - (widen) - ret)) - -;;;###autoload -(defun org-reveal-publish-to-reveal - (plist filename pub-dir) - "Publish an org file to Html. - -FILENAME is the filename of the Org file to be published. PLIST -is the property list for the given project. PUB-DIR is the -publishing directory. - -Return output file name." - (org-publish-org-to 'reveal filename ".html" plist pub-dir)) - -;; Register auto-completion for speaker notes. -(when org-reveal-note-key-char - (add-to-list 'org-structure-template-alist - (list org-reveal-note-key-char "#+BEGIN_NOTES\n\?\n#+END_NOTES"))) - -(provide 'ox-reveal) - -;;; ox-reveal.el ends here diff --git a/elpa/ox-reveal-20190918.1627/ox-reveal-autoloads.el b/elpa/ox-reveal-20190918.1627/ox-reveal-autoloads.el new file mode 100644 index 00000000..04974066 --- /dev/null +++ b/elpa/ox-reveal-20190918.1627/ox-reveal-autoloads.el @@ -0,0 +1,28 @@ +;;; ox-reveal-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +;;;### (autoloads nil "ox-reveal" "ox-reveal.el" (23994 46390 928438 +;;;;;; 537000)) +;;; Generated autoloads from ox-reveal.el + +(autoload 'org-reveal-publish-to-reveal "ox-reveal" "\ +Publish an org file to Html. + +FILENAME is the filename of the Org file to be published. PLIST +is the property list for the given project. PUB-DIR is the +publishing directory. + +Return output file name. + +\(fn PLIST FILENAME PUB-DIR)" nil nil) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; ox-reveal-autoloads.el ends here diff --git a/elpa/ox-reveal-20190918.1627/ox-reveal-pkg.el b/elpa/ox-reveal-20190918.1627/ox-reveal-pkg.el new file mode 100644 index 00000000..295d95a7 --- /dev/null +++ b/elpa/ox-reveal-20190918.1627/ox-reveal-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "ox-reveal" "20190918.1627" "reveal.js Presentation Back-End for Org Export Engine" '((org "8.3")) :commit "5fd940e01ae76ba305d46a0c0cfc4d27aa131d33" :keywords '("outlines" "hypermedia" "slideshow" "presentation") :authors '(("Yujie Wen ")) :maintainer '("Yujie Wen ")) diff --git a/elpa/ox-reveal-20190918.1627/ox-reveal.el b/elpa/ox-reveal-20190918.1627/ox-reveal.el new file mode 100644 index 00000000..93a587b9 --- /dev/null +++ b/elpa/ox-reveal-20190918.1627/ox-reveal.el @@ -0,0 +1,1337 @@ +;;; ox-reveal.el --- reveal.js Presentation Back-End for Org Export Engine + +;; Copyright (C) 2013 Yujie Wen + +;; Author: Yujie Wen +;; Created: 2013-04-27 +;; Version: 1.0 +;; Package-Version: 20190918.1627 +;; Package-Requires: ((org "8.3")) +;; Keywords: outlines, hypermedia, slideshow, presentation + +;; This file is not part of GNU Emacs. + +;;; Copyright Notice: + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;; Please see "Readme.org" for detail introductions. + +;; Pull request: Multiplex Support - Stephen Barrett \n%s\n\n" contents)) + (org-html-special-block special-block contents info)))) + +(defun org-reveal-slide-section-tag (headline info for-split) + "Generate the
tag for a slide." + (let* ((preferred-id (or (org-element-property :CUSTOM_ID headline) + (org-export-get-reference headline info))) + (default-slide-background (plist-get info :reveal-default-slide-background)) + (default-slide-background-size (plist-get info :reveal-default-slide-background-size)) + (default-slide-background-position (plist-get info :reveal-default-slide-background-position)) + (default-slide-background-repeat (plist-get info :reveal-default-slide-background-repeat)) + (default-slide-background-transition (plist-get info :reveal-default-slide-background-transition)) +) + (format "
\n" + (org-html--make-attribute-string + `(:id ,(concat org-reveal-slide-id-head + preferred-id + (if for-split "-split" "")) + :class ,(org-element-property :HTML_CONTAINER_CLASS headline) + :data-transition ,(org-element-property :REVEAL_DATA_TRANSITION headline) + :data-state ,(org-element-property :REVEAL_DATA_STATE headline) + :data-background ,(or (org-element-property :REVEAL_BACKGROUND headline) + default-slide-background) + :data-background-size ,(or (org-element-property :REVEAL_BACKGROUND_SIZE headline) + default-slide-background-size) + :data-background-position ,(or (org-element-property :REVEAL_BACKGROUND_POSITION headline) + default-slide-background-position) + :data-background-repeat ,(or (org-element-property :REVEAL_BACKGROUND_REPEAT headline) + default-slide-background-repeat) + :data-background-transition ,(or (org-element-property :REVEAL_BACKGROUND_TRANS headline) + default-slide-background-transition) + :data-background-opacity + ,(or (org-element-property :REVEAL_BACKGROUND_OPACITY headline) + (plist-get info :reveal-default-slide-background-opacity)))) + (let ((extra-attrs (org-element-property :REVEAL_EXTRA_ATTR headline))) + (if-format " %s" extra-attrs))))) + +;; Copied from org-html-headline and modified to embed org-reveal +;; specific attributes. +(defun org-reveal-headline (headline contents info) + "Transcode a HEADLINE element from Org to HTML. +CONTENTS holds the contents of the headline. INFO is a plist +holding contextual information." + (unless (org-element-property :footnote-section-p headline) + (if (org-export-low-level-p headline info) + ;; This is a deep sub-tree: export it as in ox-html. + (org-html-headline headline contents info) + ;; Standard headline. Export it as a slide + (let* ((level (org-export-get-relative-level headline info)) + (section-number (mapconcat #'number-to-string + (org-export-get-headline-number headline info) + "-")) + (hlevel (org-reveal--get-hlevel info)) + (header (plist-get info :reveal-slide-header)) + (header-div (when header (format "
%s
\n" header))) + (footer (plist-get info :reveal-slide-footer)) + (footer-div (when footer (format "
%s
\n" footer))) + (first-sibling (org-export-first-sibling-p headline info)) + (last-sibling (org-export-last-sibling-p headline info))) + (concat + (if (or (/= level 1) (not first-sibling)) + ;; Not the first heading. Close previou slide. + (concat + ;; Slide footer if any + footer-div + ;; Close previous slide + "
\n" + (if (<= level hlevel) + ;; Close previous vertical slide group. + "
\n"))) + (if (<= level hlevel) + ;; Add an extra "
" to group following slides + ;; into vertical slide group. Transition override + ;; attributes are attached at this level, too. + (let ((attrs + (org-html--make-attribute-string + `(:data-transition ,(org-element-property :REVEAL_DATA_TRANSITION headline))))) + (if (string= attrs "") + "
\n" + (format "
\n" attrs)))) + ;; Start a new slide. + (org-reveal-slide-section-tag headline info nil) + ;; Slide header if any. + header-div + ;; The HTML content of the headline + ;; Strip the
tags, if any + (let ((html (org-html-headline headline contents info))) + (if (string-prefix-p " and the last
tags from html + (concat "<" + (mapconcat 'identity + (butlast (cdr (split-string html "<" t))) + "<")) + ;; Return the HTML content unchanged + html)) + (if (and (= level 1) + (org-export-last-sibling-p headline info)) + ;; Last head 1. Close all slides. + (concat + ;; Slide footer if any + footer-div + "
\n
\n"))))))) + +(defgroup org-export-reveal nil + "Options for exporting Orgmode files to reveal.js HTML pressentations." + :tag "Org Export Reveal" + :group 'org-export) + +(defun org-reveal--read-file (file) + "Return the content of file" + (with-temp-buffer + (insert-file-contents-literally file) + (buffer-string))) + +(defun org-reveal--file-url-to-path (url) + "Convert URL that points to local files to file path." + (replace-regexp-in-string + (if (string-equal system-type "windows-nt") "^file:///" "^file://") + "" url)) + +(defun org-reveal--css-label (in-single-file file-name style-id) + "Generate an HTML label for including a CSS file, if + IN-SINGLE-FILE is t, the content of FILE-NAME is embedded, + otherwise, a `' label is generated." + (when (and file-name (not (string= file-name ""))) + (if in-single-file + ;; Single-file + (let ((local-file-name (org-reveal--file-url-to-path file-name))) + (if (file-readable-p local-file-name) + (concat "\n") + ;; But file is not readable. + (error "Cannot read %s" file-name))) + ;; Not in-single-file + (concat "\n")))) + +(defun org-reveal-stylesheets (info) + "Return the HTML contents for declaring reveal stylesheets +using custom variable `org-reveal-root'." + (let* ((root-path (file-name-as-directory (plist-get info :reveal-root))) + (reveal-css (concat root-path "css/reveal.css")) + (theme (plist-get info :reveal-theme)) + (theme-css (concat root-path "css/theme/" theme ".css")) + (extra-css (plist-get info :reveal-extra-css)) + (in-single-file (plist-get info :reveal-single-file))) + (concat + ;; Default embedded style sheets + " +" + ;; stylesheets + (mapconcat (lambda (elem) (org-reveal--css-label in-single-file (car elem) (cdr elem))) + (append (list (cons reveal-css nil) + (cons theme-css "theme")) + (mapcar (lambda (a) (cons a nil)) + (split-string extra-css "\n"))) + "\n") + + ;; Include CSS for highlight.js if necessary + (if (org-reveal--using-highlight.js info) + (format "" + (format-spec (plist-get info :reveal-highlight-css) + `((?r . ,(directory-file-name root-path)))))) + ;; print-pdf + (if in-single-file "" + (format " + + +" + root-path))))) + +(defun org-reveal-mathjax-scripts (info) + "Return the HTML contents for declaring MathJax scripts" + (if (plist-get info :reveal-mathjax) + ;; MathJax enabled. + (format "\n" + (plist-get info :reveal-mathjax-url)))) + +(defun org-reveal-scripts (info) + "Return the necessary scripts for initializing reveal.js using +custom variable `org-reveal-root'." + (let* ((root-path (file-name-as-directory (plist-get info :reveal-root))) + (reveal-js (concat root-path "js/reveal.js")) + ;; Local files + (local-root-path (org-reveal--file-url-to-path root-path)) + (local-reveal-js (concat local-root-path "js/reveal.js")) + (in-single-file (plist-get info :reveal-single-file))) + (concat + ;; reveal.js/js/reveal.js + (if (and in-single-file + (file-readable-p local-reveal-js)) + ;; Embed scripts into HTML + (concat "") + ;; Fall-back to extern script links + (if in-single-file + ;; Tried to embed scripts but failed. Print a message about possible errors. + (error (concat "Cannot read " + (mapconcat 'identity + (delq nil (mapcar (lambda (file) (if (not (file-readable-p file)) file)) + (list local-reveal-js))) + ", ")))) + (concat + "\n")) + ;; plugin headings + " +\n"))) + +(defun org-reveal-toc (depth info) + "Build a slide of table of contents." + (let ((toc (org-html-toc depth info))) + (when toc + (let ((toc-slide-with-header (plist-get info :reveal-slide-global-header)) + (toc-slide-with-footer (plist-get info :reveal-slide-global-footer))) + (concat "
\n" + (when toc-slide-with-header + (let ((header (plist-get info :reveal-slide-header))) + (when header (format "
%s
\n" header)))) + (replace-regexp-in-string "
%s
\n" footer)))) + "
\n"))))) + +(defun org-reveal-inner-template (contents info) + "Return body of document string after HTML conversion. +CONTENTS is the transcoded contents string. INFO is a plist +holding export options." + (concat + ;; Table of contents. + (let ((depth (plist-get info :with-toc))) + (when (and depth + (not (plist-get info :reveal-subtree))) + (org-reveal-toc depth info))) + ;; Document contents. + contents)) + +(defun org-reveal-parse-token (keyword info key &optional value) + "Return HTML tags or perform SIDE EFFECT according to key. +Use the previous section tag as the tag of the split section. " + (case (intern key) + (split + (let ((headline (org-element-property + :parent + (org-element-property + :parent + keyword)))) + (concat + "\n" ;; Close the previous section and start a new one. + (org-reveal-slide-section-tag headline info t) + (and value + (string= value "t") + ;; Add a title for the split slide + ;; Copy from `org-html-headline' and modified. + (let* ((title (org-export-data + (org-element-property :title headline) + info)) + (level (+ (org-export-get-relative-level headline info) + (1- (plist-get info :html-toplevel-hlevel)))) + (numberedp (org-export-numbered-headline-p headline info)) + (numbers (org-export-get-headline-number headline info))) + (format "\n%s" + level + (concat + (and numberedp + (format + "%s " + level + (mapconcat #'number-to-string numbers "."))) + title) + level)))))))) + +(defun org-reveal-parse-keyword-value (keyward value info) + "According to the value content, return HTML tags to split slides." + (let ((tokens (mapcar + (lambda (x) (split-string x ":")) + (split-string value)))) + (mapconcat + (lambda (x) (apply 'org-reveal-parse-token keyward info x)) + tokens + ""))) + +;; Copied from org-html-format-list-item. Overwrite HTML class +;; attribute when there is attr_html attributes. +(defun org-reveal-format-list-item (contents type checkbox attributes info + &optional term-counter-id + headline) + "Format a list item into HTML." + (let ((attr-html (cond (attributes (format " %s" (org-html--make-attribute-string attributes))) + (checkbox (format " class=\"%s\"" (symbol-name checkbox))) + (t ""))) + (checkbox (concat (org-html-checkbox checkbox info) + (and checkbox " "))) + (br (org-html-close-tag "br" nil info))) + (concat + (case type + (ordered + (let* ((counter term-counter-id) + (extra (if counter (format " value=\"%s\"" counter) ""))) + (concat + (format "" attr-html extra) + (when headline (concat headline br))))) + (unordered + (let* ((id term-counter-id) + (extra (if id (format " id=\"%s\"" id) ""))) + (concat + (format "" attr-html extra) + (when headline (concat headline br))))) + (descriptive + (let* ((term term-counter-id)) + (setq term (or term "(no term)")) + ;; Check-boxes in descriptive lists are associated to tag. + (concat (format "%s" + attr-html (concat checkbox term)) + (format "" attr-html))))) + (unless (eq type 'descriptive) checkbox) + (and contents (org-trim contents)) + (case type + (ordered "") + (unordered "") + (descriptive ""))))) + +;; Copied from org-html-item, changed to call +;; org-reveal-format-list-item. +(defun org-reveal-item (item contents info) + "Transcode an ITEM element from Org to Reveal. +CONTENTS holds the contents of the item. INFO is a plist holding +contextual information." + (let* ((plain-list (org-export-get-parent item)) + (type (org-element-property :type plain-list)) + (counter (org-element-property :counter item)) + (attributes (org-export-read-attribute :attr_html item)) + ; (attributes (org-html--make-attribute-string (org-export-read-attribute :attr_html item))) + (checkbox (org-element-property :checkbox item)) + (tag (let ((tag (org-element-property :tag item))) + (and tag (org-export-data tag info))))) + (org-reveal-format-list-item + contents type checkbox attributes info (or tag counter)))) + +(defun org-reveal-keyword (keyword contents info) + "Transcode a KEYWORD element from Org to Reveal, +and may change custom variables as SIDE EFFECT. +CONTENTS is nil. INFO is a plist holding contextual information." + (let ((key (org-element-property :key keyword)) + (value (org-element-property :value keyword))) + (case (intern key) + (REVEAL (org-reveal-parse-keyword-value keyword value info)) + (REVEAL_HTML value) + (HTML value)))) +(defun org-reveal-embedded-svg (path) + "Embed the SVG content into Reveal HTML." + (with-temp-buffer + (insert-file-contents-literally path) + (let ((start (re-search-forward "<[ \t\n]*svg[ \t\n]")) + (end (re-search-forward "<[ \t\n]*/svg[ \t\n]*>"))) + (concat "\n%s\n\n" + (if attrs (concat " " (org-html--make-attribute-string attrs)) "") + (org-html-latex-environment latex-env contents info)))) + +(defun org-reveal-plain-list (plain-list contents info) + "Transcode a PLAIN-LIST element from Org to Reveal. + +CONTENTS is the contents of the list. INFO is a plist holding +contextual information. + +Extract and set `attr_html' to plain-list tag attributes." + (let ((tag (case (org-element-property :type plain-list) + (ordered "ol") + (unordered "ul") + (descriptive "dl"))) + (attrs (org-export-read-attribute :attr_html plain-list))) + (format "<%s%s>\n%s\n" + tag + (if attrs (concat " " (org-html--make-attribute-string attrs)) "") + contents + tag + ))) + +(defun org-reveal--build-pre/postamble (type info) + "Return document preamble or postamble as a string, or nil." + (let ((section (plist-get info (intern (format ":reveal-%s" type)))) + (spec (org-html-format-spec info))) + (when section + (let ((section-contents + (if (functionp (intern section)) (funcall (intern section) info) + ;; else section is a string. + (format-spec section spec)))) + (when (org-string-nw-p section-contents) + (org-element-normalize-string section-contents)))))) + + +(defun org-reveal-section (section contents info) + "Transcode a SECTION element from Org to Reveal. +CONTENTS holds the contents of the section. INFO is a plist +holding contextual information." + ;; Just return the contents. No "
" tags. + contents) + +(defun org-reveal--using-highlight.js (info) + "Check whether highlight.js plugin is enabled." + (let ((reveal-plugins (condition-case e + (car (read-from-string (plist-get info :reveal-plugins))) + (end-of-file nil) + (wrong-type-argument nil)))) + (memq 'highlight (or (and reveal-plugins (listp reveal-plugins) reveal-plugins) + org-reveal-plugins)))) + +(defun org-reveal-src-block (src-block contents info) + "Transcode a SRC-BLOCK element from Org to Reveal. +CONTENTS holds the contents of the item. INFO is a plist holding +contextual information." + (if (org-export-read-attribute :attr_html src-block :textarea) + (org-html--textarea-block src-block) + (let* ((use-highlight (org-reveal--using-highlight.js info)) + (lang (org-element-property :language src-block)) + (caption (org-export-get-caption src-block)) + (code (if (not use-highlight) + (org-html-format-code src-block info) + ;; Use our own function for org-export-format-code, + ;; since org-html-format-code will wrap line + ;; numbers with HTML tags that will be display as + ;; part of the code by highlight.js + (let* ((num-start (org-export-get-loc src-block info)) + (code (car (org-export-unravel-code src-block))) + (code-length (length (split-string code "\n"))) + (num-fmt (and num-start + (format "%%%ds: " + (length (number-to-string (+ code-length + num-start))))))) + (org-export-format-code + (org-html-encode-plain-text code) + (lambda (loc line-num ref) + (setq loc + (concat + ;; Add line number, if needed + (when num-start (format num-fmt line-num)) + loc))) + num-start)))) + (frag (org-export-read-attribute :attr_reveal src-block :frag)) + (code-attribs (or (org-export-read-attribute + :attr_reveal src-block :code_attribs) "")) + (label (let ((lbl (org-element-property :name src-block))) + (if (not lbl) "" + (format " id=\"%s\"" lbl)))) + (klipsify (and org-reveal-klipsify-src + (member lang '("javascript" "js" "ruby" "scheme" "clojure" "php" "html")))) + (langselector (cond ((or (string= lang "js") (string= lang "javascript")) "selector_eval_js") + ((string= lang "clojure") "selector") + ((string= lang "python") "selector_eval_python_client") + ((string= lang "scheme") "selector_eval_scheme") + ((string= lang "ruby") "selector_eval_ruby") + ((string= lang "html") "selector_eval_html")) + ) +) + (if (not lang) + (format "
\n%s
" + (or (frag-class frag info) " class=\"example\"") + label + code) + (if klipsify + (concat + "") + (format + "
\n%s%s\n
" + (if (not caption) "" + (format "" + (org-export-data caption info))) + (if use-highlight + (format "\n%s" + (or (frag-class frag info) "") + label lang code-attribs code) + (format "\n
%s
" + (or (frag-class frag info) + (format " class=\"src src-%s\"" lang)) + label code) + ))))))) + +(defun org-reveal-quote-block (quote-block contents info) + "Transcode a QUOTE-BLOCK element from Org to Reveal. +CONTENTS holds the contents of the block INFO is a plist holding +contextual information." + (format "
\n%s
" + (frag-class (org-export-read-attribute :attr_reveal quote-block :frag) info) + contents)) + + +(defun org-reveal--auto-title-slide-template (info) + "Generate the automatic title slide template." + (let* ((spec (org-html-format-spec info)) + (title (org-export-data (plist-get info :title) info)) + (subtitle (plist-get info :subtitle)) + (author (cdr (assq ?a spec))) + (email (cdr (assq ?e spec))) + (date (cdr (assq ?d spec)))) + (concat + (when (and (plist-get info :with-title) + (org-string-nw-p title)) + (concat "

" title "

" + (if-format "

%s

\n" subtitle))) + (when (and (plist-get info :with-author) + (org-string-nw-p author)) + (concat "

" author "

")) + (when (and (plist-get info :with-email) + (org-string-nw-p email)) + (concat "

" email "

")) + (when (and (plist-get info :with-date) + (org-string-nw-p date)) + (concat "

" date "

")) + (when (plist-get info :time-stamp-file) + (concat "

" + (org-html--translate "Created" info) + ": " + (format-time-string org-html-metadata-timestamp-format) + "

"))))) + +(defun org-reveal-template (contents info) + "Return complete document string after HTML conversion. +contents is the transcoded contents string. +info is a plist holding export options." + (concat + (format "\n\n\n" + (if-format " lang=\"%s\"" (plist-get info :language))) + "\n" + (if-format "%s\n" (org-export-data (plist-get info :title) info)) + (if-format "\n" (plist-get info :author)) + (if-format "\n" (plist-get info :description)) + (if-format "\n" (plist-get info :keywords)) + (org-reveal-stylesheets info) + (org-reveal-mathjax-scripts info) + (org-reveal--build-pre/postamble 'head-preamble info) + (org-element-normalize-string (plist-get info :html-head)) + (org-element-normalize-string (plist-get info :html-head-extra)) + " +\n" + (org-reveal--build-pre/postamble 'preamble info) + "
+
\n" + ;; Title slides + (let ((title-slide (plist-get info :reveal-title-slide))) + (when (and title-slide (not (plist-get info :reveal-subtree))) + (let ((title-slide-background (plist-get info :reveal-title-slide-background)) + (title-slide-background-size (plist-get info :reveal-title-slide-background-size)) + (title-slide-background-position (plist-get info :reveal-title-slide-background-position)) + (title-slide-background-repeat (plist-get info :reveal-title-slide-background-repeat)) + (title-slide-background-transition (plist-get info :reveal-title-slide-background-transition)) + (title-slide-background-opacity (plist-get info :reveal-title-slide-background-opacity)) + (title-slide-with-header (plist-get info :reveal-slide-global-header)) + (title-slide-with-footer (plist-get info :reveal-slide-global-footer))) + (concat "
" + (when title-slide-with-header + (let ((header (plist-get info :reveal-slide-header))) + (when header (format "
%s
\n" header)))) + (cond ((eq title-slide nil) nil) + ((stringp title-slide) (format-spec title-slide (org-html-format-spec info))) + ((eq title-slide 'auto) (org-reveal--auto-title-slide-template info))) + "\n" + (when title-slide-with-footer + (let ((footer (plist-get info :reveal-slide-footer))) + (when footer (format "
%s
\n" footer)))) + "
\n")))) + contents + "
+
\n" + (org-reveal--build-pre/postamble 'postamble info) + (org-reveal-scripts info) + " +\n")) + +(defun org-reveal-filter-parse-tree (tree backend info) + "Do filtering before parsing TREE. + +Tree is the parse tree being exported. BACKEND is the export +back-end used. INFO is a plist-used as a communication channel. + +Assuming BACKEND is `reveal'. + +Each `attr_reveal' attribute is mapped to corresponding +`attr_html' attributes." + (let ((default-frag-style (plist-get info :reveal-default-frag-style))) + (org-element-map tree (remq 'item org-element-all-elements) + (lambda (elem) (org-reveal-append-frag elem default-frag-style)))) + ;; Hint for obsolete options + (when (memq t + (mapcar + (lambda (key) (plist-get info key)) + '(:reveal-control + :reveal-progress + :reveal-history + :reveal-center + :reveal-slide-number + :reveal-rolling-links + :reveal-keyboard + :reveal-overview + :reveal-width + :reveal-height + :reveal-margin + :reveal-min-scale + :reveal-max-scale + :reveal-trans + :reveal-speed))) + (with-output-to-temp-buffer + "* ox-reveal hints *" + (princ " +Note: Options and custom variables for initializing reveal.js are +obsolete. Use '#+REVEAL_INIT_OPTIONS:' instead to give JS code +snippet for initializing reveal.js. The following is a such +example: + +#+REVEAL_INIT_OPTIONS: width:1200, height:800, controlsLayout: 'edges' + +Obsolete options and variables are listed below: + + | Option | Variable | + |-----------------------+-----------------------------| + | reveal_control | org-reveal-control | + | reveal_progress | org-reveal-progress | + | reveal_history | org-reveal-history | + | reveal_center | org-reveal-center | + | reveal_slide_number | org-reveal-slide-number | + | reveal_rolling_links | org-reveal-rolling-links | + | reveal_keyboard | org-reveal-keyboard | + | reveal_overview | org-reveal-overview | + | reveal_width | org-reveal-width | + | reveal_height | org-reveal-height | + | #+REVEAL_MARGIN | org-reveal-margin | + | #+REVEAL_MIN_SCALE | org-reveal-min-scale | + | #+REVEAL_MAX_SCALE | org-reveal-max-scale | + | #+REVEAL_TRANS | org-reveal-transition | + | #+REVEAL_SPEED | org-reveal-transition-speed | +"))) + ;; Return the updated tree. + tree) + +(defun org-reveal--update-attr-html (elem frag default-style &optional frag-index) + "Update ELEM's attr_html attribute with reveal's +fragment attributes." + (let ((attr-html (org-element-property :attr_html elem))) + (when (and frag (not (string= frag "none"))) + (push (cond ((string= frag t) + (if default-style (format ":class fragment %s" default-style) + ":class fragment")) + (t (format ":class fragment %s" frag))) + attr-html) + (when frag-index + (push (format ":data-fragment-index %s" frag-index) attr-html))) + (org-element-put-property elem :attr_html attr-html))) + +(defun org-reveal-append-frag (elem default-style) + "Read org-reveal's fragment attribute from ELEM and append +transformed fragment attribute to ELEM's attr_html plist." + (let ((frag (org-export-read-attribute :attr_reveal elem :frag)) + (frag-index (org-export-read-attribute :attr_reveal elem :frag_idx))) + (if frag + (cond ((and (string= (org-element-type elem) 'plain-list) + (char-equal (string-to-char frag) ?\()) + (let* ((frag-list (car (read-from-string frag))) + (frag-list (if default-style + (mapcar (lambda (s) + "Replace t with default-style" + (if (string= s t) default-style + s)) + frag-list) + frag-list)) + (items (org-element-contents elem)) + (default-style-list + (mapcar (lambda (a) default-style) + (number-sequence 1 (length items))))) + (if frag-index + (mapcar* 'org-reveal--update-attr-html + items frag-list default-style-list (car (read-from-string frag-index))) + (let* ((last-frag (car (last frag-list))) + (tail-list (mapcar (lambda (a) last-frag) + (number-sequence (+ (length frag-list) 1) + (length items))))) + (nconc frag-list tail-list) + (mapcar* 'org-reveal--update-attr-html items frag-list default-style-list))))) + (t (org-reveal--update-attr-html elem frag default-style frag-index))) + elem))) + +(defvar client-multiplex nil + "used to cause generation of client html file for multiplex") + +(defun org-reveal-export-to-html + (&optional async subtreep visible-only body-only ext-plist) + "Export current buffer to a reveal.js HTML file." + (interactive) + (let* ((extension (concat "." org-html-extension)) + (file (org-export-output-file-name extension subtreep)) + (clientfile (org-export-output-file-name (concat "_client" extension) subtreep))) + ; export filename_client HTML file if multiplexing + (setq client-multiplex nil) + (setq retfile (org-export-to-file 'reveal file + async subtreep visible-only body-only ext-plist)) + + ; export the client HTML file if client-multiplex is set true + ; by previous call to org-export-to-file + (if (eq client-multiplex t) + (org-export-to-file 'reveal clientfile + async subtreep visible-only body-only ext-plist)) + retfile)) + +(defun org-reveal-export-to-html-and-browse + (&optional async subtreep visible-only body-only ext-plist) + "Export current buffer to a reveal.js and browse HTML file." + (interactive) + (browse-url-of-file (expand-file-name (org-reveal-export-to-html async subtreep visible-only body-only ext-plist)))) + +(defun org-reveal-export-current-subtree + (&optional async subtreep visible-only body-only ext-plist) + "Export current subtree to a Reveal.js HTML file." + (interactive) + (org-narrow-to-subtree) + (let ((ret (org-reveal-export-to-html async subtreep visible-only body-only (plist-put ext-plist :reveal-subtree t)))) + (widen) + (message "Obsoleting soon. Use the \"Export scope\" switch instead to utilize parent heading properties.") + ret)) + +;; Generate a heading of ToC for current buffer and write to current +;; point +(defun org-reveal-manual-toc (gh-links) + (interactive "P") + (insert ;; at current point + (mapconcat + 'identity + (org-element-map (org-element-parse-buffer) 'headline + (lambda (headline) + (let ((title (org-element-property :raw-value headline))) + (concat + ;; Leading spaces by headline level + (make-string (* 2 (org-element-property :level headline)) ?\s) + "- [[" + title + "][" + title + "]]" + (when gh-links + ;; Add another link to github readme page + (concat + "([[https://github.com/yjwen/org-reveal#" + ;; Follow the github link-naming convension + (replace-regexp-in-string + ;; remove any non-alphanum character + "[.,']" + "" + (replace-regexp-in-string + ;; Any spaces with hyphen + " +" "-" + (downcase title))) + "][gh]])") + ))))) + "\n"))) +;;;###autoload +(defun org-reveal-publish-to-reveal + (plist filename pub-dir) + "Publish an org file to Html. + +FILENAME is the filename of the Org file to be published. PLIST +is the property list for the given project. PUB-DIR is the +publishing directory. + +Return output file name." + (org-publish-org-to 'reveal filename ".html" plist pub-dir)) + +;; Register auto-completion for speaker notes. +(when org-reveal-note-key-char + (if (version< (cdr (get 'org-structure-template-alist 'custom-package-version)) "9.2") + (add-to-list 'org-structure-template-alist + (list org-reveal-note-key-char "#+BEGIN_NOTES\n\?\n#+END_NOTES")) + (add-to-list 'org-structure-template-alist + (cons org-reveal-note-key-char "notes")))) + +(provide 'ox-reveal) + +;;; ox-reveal.el ends here