mirror of https://github.com/yjwen/org-reveal.git
Fix bug in generating list fragment. Merged from master branch.
This commit is contained in:
commit
3a1205e3b0
|
@ -308,10 +308,8 @@ $ git clone https://github.com/yjwen/org-reveal.git
|
||||||
#+ATTR_REVEAL: :frag roll-in
|
#+ATTR_REVEAL: :frag roll-in
|
||||||
Pictures, tables and many other HTML elements can be fragmented.
|
Pictures, tables and many other HTML elements can be fragmented.
|
||||||
|
|
||||||
Use default fragment style by setting ":frag t".
|
|
||||||
|
|
||||||
*** Fragment Styles
|
*** Fragment Styles
|
||||||
Availabe fragment styles are:
|
Available fragment styles are:
|
||||||
#+ATTR_REVEAL: :frag t
|
#+ATTR_REVEAL: :frag t
|
||||||
* grow
|
* grow
|
||||||
* shrink
|
* shrink
|
||||||
|
@ -321,6 +319,10 @@ $ git clone https://github.com/yjwen/org-reveal.git
|
||||||
* highlight-green
|
* highlight-green
|
||||||
* highlight-blue
|
* highlight-blue
|
||||||
|
|
||||||
|
Setting ~:frag t~ will use Reveal.js default fragment style, which
|
||||||
|
can be overriden by local option ~#+REVEAL_DEFAULT_FRAG_STYLE~ or
|
||||||
|
global variable ~org-reveal-default-frag-style~.
|
||||||
|
|
||||||
*** Fragment Index
|
*** Fragment Index
|
||||||
Fragment sequence can be changed by assigning adding ~:frag_idx~
|
Fragment sequence can be changed by assigning adding ~:frag_idx~
|
||||||
property to each fragmented element.
|
property to each fragmented element.
|
||||||
|
|
69
ox-reveal.el
69
ox-reveal.el
|
@ -34,14 +34,6 @@
|
||||||
(require 'ox-html)
|
(require 'ox-html)
|
||||||
(eval-when-compile (require 'cl))
|
(eval-when-compile (require 'cl))
|
||||||
|
|
||||||
(defun frag-style (frag)
|
|
||||||
"Return \"fragment\" if frag is t, which indicates to use
|
|
||||||
default fragment style, otherwise return \"fragment style\"."
|
|
||||||
(cond
|
|
||||||
((string= frag t) "fragment")
|
|
||||||
(t (format "fragment %s" frag))))
|
|
||||||
|
|
||||||
|
|
||||||
(org-export-define-derived-backend 'reveal 'html
|
(org-export-define-derived-backend 'reveal 'html
|
||||||
|
|
||||||
:menu-entry
|
:menu-entry
|
||||||
|
@ -88,6 +80,7 @@ default fragment style, otherwise return \"fragment style\"."
|
||||||
(:reveal-slide-header "REVEAL_SLIDE_HEADER" nil org-reveal-slide-header t)
|
(:reveal-slide-header "REVEAL_SLIDE_HEADER" nil org-reveal-slide-header t)
|
||||||
(:reveal-slide-footer "REVEAL_SLIDE_FOOTER" nil org-reveal-slide-footer t)
|
(:reveal-slide-footer "REVEAL_SLIDE_FOOTER" nil org-reveal-slide-footer t)
|
||||||
(:reveal-plugins "REVEAL_PLUGINS" nil nil t)
|
(:reveal-plugins "REVEAL_PLUGINS" nil nil t)
|
||||||
|
(:reveal-default-frag-style "REVEAL_DEFAULT_FRAG_STYLE" nil org-reveal-default-frag-style t)
|
||||||
)
|
)
|
||||||
|
|
||||||
:translate-alist
|
:translate-alist
|
||||||
|
@ -289,6 +282,11 @@ can be include."
|
||||||
:group 'org-export-reveal
|
:group 'org-export-reveal
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
|
(defcustom org-reveal-default-frag-style nil
|
||||||
|
"Default fragment style."
|
||||||
|
:group 'org-export-reveal
|
||||||
|
:type 'string)
|
||||||
|
|
||||||
(defcustom org-reveal-plugins
|
(defcustom org-reveal-plugins
|
||||||
'(classList markdown highlight zoom notes)
|
'(classList markdown highlight zoom notes)
|
||||||
"Default builtin plugins"
|
"Default builtin plugins"
|
||||||
|
@ -306,10 +304,23 @@ can be include."
|
||||||
(defun if-format (fmt val)
|
(defun if-format (fmt val)
|
||||||
(if val (format fmt val) ""))
|
(if val (format fmt val) ""))
|
||||||
|
|
||||||
(defun frag-class (frag)
|
(defun frag-style (frag info)
|
||||||
;; Return proper HTML string description of fragment style.
|
"Return proper fragment string according to FRAG and the default fragment style.
|
||||||
|
FRAG is the fragment style set on element, INFO is a plist
|
||||||
|
holding contextual information."
|
||||||
|
(cond
|
||||||
|
((string= frag t)
|
||||||
|
(let ((default-frag-style (plist-get info :reveal-default-frag-style)))
|
||||||
|
(if default-frag-style (format "fragment %s" default-frag-style)
|
||||||
|
"fragment")))
|
||||||
|
(t (format "fragment %s" frag))))
|
||||||
|
|
||||||
|
(defun frag-class (frag 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
|
(and frag
|
||||||
(format " class=\"%s\"" (frag-style frag))))
|
(format " class=\"%s\"" (frag-style frag info))))
|
||||||
|
|
||||||
(defun org-reveal-export-block (export-block contents info)
|
(defun org-reveal-export-block (export-block contents info)
|
||||||
"Transocde a EXPORT-BLOCK element from Org to Reveal.
|
"Transocde a EXPORT-BLOCK element from Org to Reveal.
|
||||||
|
@ -673,7 +684,7 @@ Extract and set `attr_html' to plain-list tag attributes."
|
||||||
(attrs (org-export-read-attribute :attr_html plain-list)))
|
(attrs (org-export-read-attribute :attr_html plain-list)))
|
||||||
(format "<%s%s>\n%s\n</%s>"
|
(format "<%s%s>\n%s\n</%s>"
|
||||||
tag
|
tag
|
||||||
(if attrs (org-html--make-attribute-string attrs) "")
|
(if attrs (concat " " (org-html--make-attribute-string attrs)) "")
|
||||||
contents
|
contents
|
||||||
tag)))
|
tag)))
|
||||||
|
|
||||||
|
@ -683,7 +694,7 @@ CONTENTS is the contents of the paragraph, as a string. INFO is
|
||||||
the plist used as a communication channel."
|
the plist used as a communication channel."
|
||||||
(let ((frag (org-export-read-attribute :attr_reveal paragraph :frag))
|
(let ((frag (org-export-read-attribute :attr_reveal paragraph :frag))
|
||||||
(html (org-html-paragraph paragraph contents info)))
|
(html (org-html-paragraph paragraph contents info)))
|
||||||
(if frag (format "<span%s>%s</span>" (frag-class frag) html)
|
(if frag (format "<span%s>%s</span>" (frag-class frag info) html)
|
||||||
html)))
|
html)))
|
||||||
|
|
||||||
(defun org-reveal--build-pre/postamble (type info)
|
(defun org-reveal--build-pre/postamble (type info)
|
||||||
|
@ -722,7 +733,7 @@ contextual information."
|
||||||
(org-export-solidify-link-text lbl))))))
|
(org-export-solidify-link-text lbl))))))
|
||||||
(if (not lang)
|
(if (not lang)
|
||||||
(format "<pre %s%s>\n%s</pre>"
|
(format "<pre %s%s>\n%s</pre>"
|
||||||
(or (frag-class frag) " class=\"example\"")
|
(or (frag-class frag info) " class=\"example\"")
|
||||||
label
|
label
|
||||||
code)
|
code)
|
||||||
(format
|
(format
|
||||||
|
@ -731,7 +742,7 @@ contextual information."
|
||||||
(format "<label class=\"org-src-name\">%s</label>"
|
(format "<label class=\"org-src-name\">%s</label>"
|
||||||
(org-export-data caption info)))
|
(org-export-data caption info)))
|
||||||
(format "\n<pre %s%s>%s</pre>"
|
(format "\n<pre %s%s>%s</pre>"
|
||||||
(or (frag-class frag)
|
(or (frag-class frag info)
|
||||||
(format " class=\"src src-%s\"" lang))
|
(format " class=\"src src-%s\"" lang))
|
||||||
label code))))))
|
label code))))))
|
||||||
|
|
||||||
|
@ -739,8 +750,8 @@ contextual information."
|
||||||
"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))
|
(frag-class (org-export-read-attribute :attr_reveal quote-block :frag) info)
|
||||||
contents))
|
contents))
|
||||||
|
|
||||||
|
|
||||||
|
@ -797,8 +808,9 @@ Assuming BACKEND is `reveal'.
|
||||||
|
|
||||||
Each `attr_reveal' attribute is mapped to corresponding
|
Each `attr_reveal' attribute is mapped to corresponding
|
||||||
`attr_html' attributes."
|
`attr_html' attributes."
|
||||||
(org-element-map tree (remq 'item org-element-all-elements)
|
(let ((default-frag-style (plist-get info :reveal-default-frag-style)))
|
||||||
'org-reveal-append-frag)
|
(org-element-map tree (remq 'item org-element-all-elements)
|
||||||
|
(lambda (elem) (org-reveal-append-frag elem default-frag-style))))
|
||||||
;; Return the updated tree.
|
;; Return the updated tree.
|
||||||
tree)
|
tree)
|
||||||
|
|
||||||
|
@ -814,7 +826,7 @@ fragment attributes."
|
||||||
(push (format ":data-fragment-index %s" frag-index) attr-html)))
|
(push (format ":data-fragment-index %s" frag-index) attr-html)))
|
||||||
(org-element-put-property elem :attr_html attr-html)))
|
(org-element-put-property elem :attr_html attr-html)))
|
||||||
|
|
||||||
(defun org-reveal-append-frag (elem)
|
(defun org-reveal-append-frag (elem default-style)
|
||||||
"Read org-reveal's fragment attribute from ELEM and append
|
"Read org-reveal's fragment attribute from ELEM and append
|
||||||
transformed fragment attribute to ELEM's attr_html plist."
|
transformed fragment attribute to ELEM's attr_html plist."
|
||||||
(let ((frag (org-export-read-attribute :attr_reveal elem :frag))
|
(let ((frag (org-export-read-attribute :attr_reveal elem :frag))
|
||||||
|
@ -822,12 +834,21 @@ transformed fragment attribute to ELEM's attr_html plist."
|
||||||
(if frag
|
(if frag
|
||||||
(cond ((and (string= (org-element-type elem) 'plain-list)
|
(cond ((and (string= (org-element-type elem) 'plain-list)
|
||||||
(char-equal (string-to-char frag) ?\())
|
(char-equal (string-to-char frag) ?\())
|
||||||
(let ((frag-list (car (read-from-string frag)))
|
(let* ((frag-list (car (read-from-string frag)))
|
||||||
(items (org-element-contents elem)))
|
(frag-list-mapped (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)))
|
||||||
|
(message "default-style: %s" default-style)
|
||||||
|
(message "frag-list-mapped: %s" frag-list-mapped)
|
||||||
(if frag-index
|
(if frag-index
|
||||||
(mapcar* 'org-reveal--update-attr-html
|
(mapcar* 'org-reveal--update-attr-html
|
||||||
items frag-list (car (read-from-string frag-index)))
|
items frag-list-mapped (car (read-from-string frag-index)))
|
||||||
(mapcar* 'org-reveal--update-attr-html items frag-list))))
|
(mapcar* 'org-reveal--update-attr-html items frag-list-mapped))))
|
||||||
(t (org-reveal--update-attr-html elem frag frag-index))))
|
(t (org-reveal--update-attr-html elem frag frag-index))))
|
||||||
elem))
|
elem))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue