Fixed #449. Correct data-id for source code by highlight plugin

This commit is contained in:
Yujie Wen 2021-08-27 23:55:01 +08:00
parent 8eae719acc
commit 0bfb526839
2 changed files with 56 additions and 13 deletions

View File

@ -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~

View File

@ -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 "<pre %s%s>\n%s</pre>"
(or (frag-class src-block info) " class=\"example\"")
label
(format "<pre %s>\n%s</pre>"
(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 "<label class=\"org-src-name\">%s</label>"
(org-export-data caption info)))
(if use-highlight
(format "\n<pre%s%s><code class=\"%s\" %s>%s</code></pre>"
(or (frag-class src-block info) "")
label lang code-attribs code)
(format "\n<pre %s%s %s><code trim>%s</code></pre>"
(or (frag-class src-block info)
(format " class=\"src src-%s\"" lang))
label code-attribs code))))))))
(format "\n<pre %s><code class=\"%s\" %s>%s</code></pre>"
(string-join (list (or (frag-class src-block info) "")
label
data-id)
" ")
lang code-attribs code)
(format "\n<pre %s><code trim>%s</code></pre>"
(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.