From 3cc34ac52b5b27c71b8b3195e8bec59919abe376 Mon Sep 17 00:00:00 2001 From: Yujie Wen Date: Wed, 4 Mar 2020 17:35:05 +0800 Subject: [PATCH] Fixed #412. Add frag index support for source blocks --- ox-reveal.el | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/ox-reveal.el b/ox-reveal.el index 3572aaa..3dab631 100644 --- a/ox-reveal.el +++ b/ox-reveal.el @@ -350,12 +350,18 @@ holding contextual information." "fragment"))) (t (format "fragment %s" frag)))) -(defun frag-class (frag info) +(defun frag-class (elem info) "Return proper HTML string description of fragment style. -FRAG is the fragment style set on element, INFO is a plist -holding contextual information." - (and frag - (format " class=\"%s\"" (frag-style frag info)))) +BLOCK is the element, INFO is a plist holding contextual +information." + (let ((frag (org-export-read-attribute :attr_reveal elem :frag))) + (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) "Transcode a SPECIAL-BLOCK element from Org to Reveal. @@ -963,7 +969,6 @@ contextual information." (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))) @@ -980,8 +985,8 @@ contextual information." ) ) (if (not lang) - (format "
\n%s
" - (or (frag-class frag info) " class=\"example\"") + (format "
\n%s
" + (or (frag-class src-block info) " class=\"example\"")) label code) (if klipsify @@ -1016,20 +1021,20 @@ window.klipse_settings = { " langselector ": \".klipse\" }; (org-export-data caption info))) (if use-highlight (format "\n%s" - (or (frag-class frag info) "") + (or (frag-class src-block info) "") label lang code-attribs code) (format "\n
%s
" - (or (frag-class frag info) + (or (frag-class src-block info) (format " class=\"src src-%s\"" lang)) - label code) - ))))))) + 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) + (or (frag-class quote-block info) + "") contents))