Add fragment index to element's HTML attributes.

This commit is contained in:
Yujie Wen 2015-03-03 23:53:36 +08:00
parent 13106f3da3
commit 4966b83002
1 changed files with 35 additions and 25 deletions

View File

@ -803,7 +803,10 @@ 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) (org-element-map tree (remq 'item org-element-all-elements)
'org-reveal-append-frag) (lambda (elem)
"Append ELEM's fragment attributes."
(org-reveal-append-frag elem)
(org-reveal-append-frag-index elem)))
;; Return the updated tree. ;; Return the updated tree.
tree) tree)
@ -812,32 +815,39 @@ Each `attr_reveal' attribute is mapped to corresponding
transformed fragment attribute to ELEM's attr_html plist." transformed fragment attribute to ELEM's attr_html plist."
(let ((frag-attr (org-export-read-attribute :attr_reveal elem :frag))) (let ((frag-attr (org-export-read-attribute :attr_reveal elem :frag)))
(if frag-attr (if frag-attr
(let ((attr-html (org-element-property :attr_html elem)) (cond
(elem-type (org-element-type elem))) ((and (string= (org-element-type elem) 'plain-list)
(cond (char-equal (string-to-char frag-attr) ?\())
((and (string= elem-type 'plain-list) (mapcar*
(char-equal (string-to-char frag-attr) ?\()) (lambda (item frag)
(mapcar* "Overwrite item's `:checkbox' property with reveal's
(lambda (item frag) fragment attribute."
"Overwrite item's `:checkbox' property with (and (not (string= frag "none"))
reveal's fragment attribute." (org-element-put-property
(and (not (string= frag "none")) item :checkbox
(org-element-put-property (intern (cond ((string= frag t) "fragment")
item :checkbox (t (format "fragment %s" frag)))))))
(intern (cond ((string= frag t) "fragment") (org-element-contents elem)
(t (format "fragment %s" frag))))))) (car (read-from-string frag-attr))))
(org-element-contents elem) (t
(car (read-from-string frag-attr)))) ;; Convert reveal's fragment attribute to HTML attribute.
(t (let ((attr-html (org-element-property :attr_html elem)))
;; Convert reveal's fragment attribute to HTML attribute. (push
(let ((attr-html (org-element-property :attr_html elem))) (cond ((string= frag-attr t) ":class fragment")
(push (t (concat ":class fragment " frag-attr)))
(cond ((string= frag-attr t) ":class fragment") attr-html)
(t (concat ":class fragment " frag-attr))) (org-element-put-property elem :attr_html attr-html)))))
attr-html)
(org-element-put-property elem :attr_html attr-html))))))
elem)) elem))
(defun org-reveal-append-frag-index (elem)
"Read org-reveal's fragment index from ELEM and append
transformed fragment index attribute to ELEM's atr_html plist."
(let ((frag-index (org-export-read-attribute :attr_reveal elem :frag_idx)))
(if frag-index
(let ((attr-html (org-element-property :attr_html elem)))
(push (concat ":data-fragment-index " frag-index) attr-html)
(org-element-put-property elem :attr_html attr-html)))))
(defvar client-multiplex nil (defvar client-multiplex nil
"used to cause generation of client html file for multiplex") "used to cause generation of client html file for multiplex")