From 0bfb526839aaae8fe755dd2b75ae06dfe7f08f31 Mon Sep 17 00:00:00 2001 From: Yujie Wen Date: Fri, 27 Aug 2021 23:55:01 +0800 Subject: [PATCH] Fixed #449. Correct data-id for source code by highlight plugin --- Readme.org | 33 +++++++++++++++++++++++++++++++++ ox-reveal.el | 36 +++++++++++++++++++++++------------- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/Readme.org b/Readme.org index e15b911..4a34515 100644 --- a/Readme.org +++ b/Readme.org @@ -59,6 +59,7 @@ - [[By Local Option Line][By Local Option Line]]([[https://github.com/yjwen/org-reveal#by-local-option-line][gh]]) - [[Highlight Source Code][Highlight Source Code]]([[https://github.com/yjwen/org-reveal#highlight-source-code][gh]]) - [[Using highlight.js][Using highlight.js]]([[https://github.com/yjwen/org-reveal#using-highlightjs][gh]]) + - [[Auto-Animate]] - [[Editable Source Code][Editable Source Code]]([[https://github.com/yjwen/org-reveal#editable-source-code][gh]]) - [[MathJax][MathJax]]([[https://github.com/yjwen/org-reveal#mathjax][gh]]) #+REVEAL: split:t @@ -630,6 +631,38 @@ int main() ,#+END_SRC #+END_SRC +** Auto-Animate + To enable [[https://revealjs.com/auto-animate/][auto-animate]], please add ~data-auto-animate~ to heading's + ~REVEAL_EXTRA_ATTR~ property. To force Reveal.js to match source + codes across slides, please add the same ~:data_id foo~ to the + ~#+ADDR_REVEAL:~ tag of the source code blocks. Example as below. + #+begin_src org + ,* Heading 1 + :PROPERTIES: + :REVEAL_EXTRA_ATTR: data-auto-animate + :END: + + ,#+ATTR_REVEAL: :data_id foo + ,#+begin_src js + let index = 1 + ,#+end_src + + + ,* Heading 2 + :PROPERTIES: + :REVEAL_EXTRA_ATTR: data-auto-animate + :END: + + + ,#+ATTR_REVEAL: :data_id foo + ,#+begin_src js + let index = 1 + let value = 2 + ,#+end_src + + #+end_src + + ** Editable Source Code It is now possible to embed code blocks in a codemirror instance in order to edit code during a presentation. At present, this capacity is turned on or off at time export using these defcustoms: - ~org-reveal-klipsify-src~ diff --git a/ox-reveal.el b/ox-reveal.el index a9ffc8d..406ceb0 100644 --- a/ox-reveal.el +++ b/ox-reveal.el @@ -1161,9 +1161,9 @@ contextual information." num-start)))) (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)))) + (data-id (if-format " data-id=\"%s\"" (org-export-read-attribute + :attr_reveal src-block :data_id))) + (label (if-format "id=\"%s\"" (org-element-property :name src-block))) (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") @@ -1174,9 +1174,11 @@ contextual information." ((string= lang "html") "selector_eval_html")) )) (if (not lang) - (format "
\n%s
" - (or (frag-class src-block info) " class=\"example\"") - label + (format "
\n%s
" + (string-join (list (or (frag-class src-block info) " class=\"example\"") + label) + " ") + code) (if klipsify (concat @@ -1209,13 +1211,21 @@ window.klipse_settings = { " langselector ": \".klipse\" }; (format "" (org-export-data caption info))) (if use-highlight - (format "\n%s" - (or (frag-class src-block info) "") - label lang code-attribs code) - (format "\n
%s
" - (or (frag-class src-block info) - (format " class=\"src src-%s\"" lang)) - label code-attribs code)))))))) + (format "\n
%s
" + (string-join (list (or (frag-class src-block info) "") + label + data-id) + " ") + lang code-attribs code) + (format "\n
%s
" + (string-join (list (or (frag-class src-block info) + (format " class=\"src src-%s\"" lang)) + label + data-id + code-attribs) + " ") + + code)))))))) (defun org-reveal-quote-block (quote-block contents info) "Transcode a QUOTE-BLOCK element from Org to Reveal.