Fixed #412. Add frag index support for source blocks

This commit is contained in:
Yujie Wen 2020-03-04 17:35:05 +08:00
parent e35457c543
commit 3cc34ac52b
1 changed files with 18 additions and 13 deletions

View File

@ -350,12 +350,18 @@ holding contextual information."
"fragment"))) "fragment")))
(t (format "fragment %s" frag)))) (t (format "fragment %s" frag))))
(defun frag-class (frag info) (defun frag-class (elem info)
"Return proper HTML string description of fragment style. "Return proper HTML string description of fragment style.
FRAG is the fragment style set on element, INFO is a plist BLOCK is the element, INFO is a plist holding contextual
holding contextual information." information."
(and frag (let ((frag (org-export-read-attribute :attr_reveal elem :frag)))
(format " class=\"%s\"" (frag-style frag info)))) (and frag
(format " class=\"%s\"%s"
(frag-style frag info)
(let ((frag-index (org-export-read-attribute :attr_reveal elem :frag_idx)))
(if frag-index
(format " data-fragment-index=\"%s\"" frag-index)
""))))))
(defun org-reveal-special-block (special-block contents info) (defun org-reveal-special-block (special-block contents info)
"Transcode a SPECIAL-BLOCK element from Org to Reveal. "Transcode a SPECIAL-BLOCK element from Org to Reveal.
@ -963,7 +969,6 @@ contextual information."
(when num-start (format num-fmt line-num)) (when num-start (format num-fmt line-num))
loc))) loc)))
num-start)))) num-start))))
(frag (org-export-read-attribute :attr_reveal src-block :frag))
(code-attribs (or (org-export-read-attribute (code-attribs (or (org-export-read-attribute
:attr_reveal src-block :code_attribs) "")) :attr_reveal src-block :code_attribs) ""))
(label (let ((lbl (org-element-property :name src-block))) (label (let ((lbl (org-element-property :name src-block)))
@ -980,8 +985,8 @@ contextual information."
) )
) )
(if (not lang) (if (not lang)
(format "<pre %s%s>\n%s</pre>" (format "<pre %s%s%s>\n%s</pre>"
(or (frag-class frag info) " class=\"example\"") (or (frag-class src-block info) " class=\"example\""))
label label
code) code)
(if klipsify (if klipsify
@ -1016,20 +1021,20 @@ window.klipse_settings = { " langselector ": \".klipse\" };
(org-export-data caption info))) (org-export-data caption info)))
(if use-highlight (if use-highlight
(format "\n<pre%s%s><code class=\"%s\" %s>%s</code></pre>" (format "\n<pre%s%s><code class=\"%s\" %s>%s</code></pre>"
(or (frag-class frag info) "") (or (frag-class src-block info) "")
label lang code-attribs code) label lang code-attribs code)
(format "\n<pre %s%s><code trim>%s</code></pre>" (format "\n<pre %s%s><code trim>%s</code></pre>"
(or (frag-class frag info) (or (frag-class src-block info)
(format " class=\"src src-%s\"" lang)) (format " class=\"src src-%s\"" lang))
label code) label code)))))))
)))))))
(defun org-reveal-quote-block (quote-block contents info) (defun org-reveal-quote-block (quote-block contents info)
"Transcode a QUOTE-BLOCK element from Org to Reveal. "Transcode a QUOTE-BLOCK element from Org to Reveal.
CONTENTS holds the contents of the block INFO is a plist holding CONTENTS holds the contents of the block INFO is a plist holding
contextual information." contextual information."
(format "<blockquote %s>\n%s</blockquote>" (format "<blockquote %s>\n%s</blockquote>"
(frag-class (org-export-read-attribute :attr_reveal quote-block :frag) info) (or (frag-class quote-block info)
"")
contents)) contents))