mirror of https://github.com/yjwen/org-reveal.git
Support attr_html attributes in list items.
This commit is contained in:
parent
4966b83002
commit
a79ec359d9
101
ox-reveal.el
101
ox-reveal.el
|
@ -92,6 +92,7 @@ default fragment style, otherwise return \"fragment style\"."
|
||||||
'((export-block . org-reveal-export-block)
|
'((export-block . org-reveal-export-block)
|
||||||
(headline . org-reveal-headline)
|
(headline . org-reveal-headline)
|
||||||
(inner-template . org-reveal-inner-template)
|
(inner-template . org-reveal-inner-template)
|
||||||
|
(item . org-reveal-item)
|
||||||
(keyword . org-reveal-keyword)
|
(keyword . org-reveal-keyword)
|
||||||
(plain-list . org-reveal-plain-list)
|
(plain-list . org-reveal-plain-list)
|
||||||
(quote-block . org-reveal-quote-block)
|
(quote-block . org-reveal-quote-block)
|
||||||
|
@ -666,6 +667,62 @@ holding export options."
|
||||||
tokens
|
tokens
|
||||||
"")))
|
"")))
|
||||||
|
|
||||||
|
;; Copied from org-html-format-list-item. Overwrite HTML class
|
||||||
|
;; attribute when there is attr_html attributes.
|
||||||
|
(defun org-reveal-format-list-item (contents type checkbox attributes info
|
||||||
|
&optional term-counter-id
|
||||||
|
headline)
|
||||||
|
"Format a list item into HTML."
|
||||||
|
(let ((attr-html (cond (attributes (format " %s" (org-html--make-attribute-string attributes)))
|
||||||
|
(checkbox (format " class=\"%s\"" (symbol-name checkbox)))
|
||||||
|
(t "")))
|
||||||
|
(checkbox (concat (org-html-checkbox checkbox info)
|
||||||
|
(and checkbox " ")))
|
||||||
|
(br (org-html-close-tag "br" nil info)))
|
||||||
|
(concat
|
||||||
|
(case type
|
||||||
|
(ordered
|
||||||
|
(let* ((counter term-counter-id)
|
||||||
|
(extra (if counter (format " value=\"%s\"" counter) "")))
|
||||||
|
(concat
|
||||||
|
(format "<li%s%s>" attr-html extra)
|
||||||
|
(when headline (concat headline br)))))
|
||||||
|
(unordered
|
||||||
|
(let* ((id term-counter-id)
|
||||||
|
(extra (if id (format " id=\"%s\"" id) "")))
|
||||||
|
(concat
|
||||||
|
(format "<li%s%s>" attr-html extra)
|
||||||
|
(when headline (concat headline br)))))
|
||||||
|
(descriptive
|
||||||
|
(let* ((term term-counter-id))
|
||||||
|
(setq term (or term "(no term)"))
|
||||||
|
;; Check-boxes in descriptive lists are associated to tag.
|
||||||
|
(concat (format "<dt%s>%s</dt>"
|
||||||
|
attr-html (concat checkbox term))
|
||||||
|
"<dd>"))))
|
||||||
|
(unless (eq type 'descriptive) checkbox)
|
||||||
|
(and contents (org-trim contents))
|
||||||
|
(case type
|
||||||
|
(ordered "</li>")
|
||||||
|
(unordered "</li>")
|
||||||
|
(descriptive "</dd>")))))
|
||||||
|
|
||||||
|
;; Copied from org-html-item, changed to call
|
||||||
|
;; org-reveal-format-list-item.
|
||||||
|
(defun org-reveal-item (item contents info)
|
||||||
|
"Transcode an ITEM element from Org to Reveal.
|
||||||
|
CONTENTS holds the contents of the item. INFO is a plist holding
|
||||||
|
contextual information."
|
||||||
|
(let* ((plain-list (org-export-get-parent item))
|
||||||
|
(type (org-element-property :type plain-list))
|
||||||
|
(counter (org-element-property :counter item))
|
||||||
|
(attributes (org-export-read-attribute :attr_html item))
|
||||||
|
; (attributes (org-html--make-attribute-string (org-export-read-attribute :attr_html item)))
|
||||||
|
(checkbox (org-element-property :checkbox item))
|
||||||
|
(tag (let ((tag (org-element-property :tag item)))
|
||||||
|
(and tag (org-export-data tag info)))))
|
||||||
|
(org-reveal-format-list-item
|
||||||
|
contents type checkbox attributes info (or tag counter))))
|
||||||
|
|
||||||
(defun org-reveal-keyword (keyword contents info)
|
(defun org-reveal-keyword (keyword contents info)
|
||||||
"Transcode a KEYWORD element from Org to HTML,
|
"Transcode a KEYWORD element from Org to HTML,
|
||||||
|
@ -810,33 +867,33 @@ Each `attr_reveal' attribute is mapped to corresponding
|
||||||
;; Return the updated tree.
|
;; Return the updated tree.
|
||||||
tree)
|
tree)
|
||||||
|
|
||||||
|
(defun org-reveal--update-attr-html (elem frag-attr)
|
||||||
|
"Update ELEM's attr_html atrribute with reveal's
|
||||||
|
fragment attributes."
|
||||||
|
(let ((attr-html (org-element-property :attr_html elem)))
|
||||||
|
(push (cond ((string= frag-attr t) ":class fragment")
|
||||||
|
(t (format ":class fragment %s" frag-attr)))
|
||||||
|
attr-html)
|
||||||
|
(org-element-put-property elem :attr_html attr-html)))
|
||||||
|
|
||||||
(defun org-reveal-append-frag (elem)
|
(defun org-reveal-append-frag (elem)
|
||||||
"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-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
|
||||||
(cond
|
(cond ((and (string= (org-element-type elem) 'plain-list)
|
||||||
((and (string= (org-element-type elem) 'plain-list)
|
(char-equal (string-to-char frag-attr) ?\())
|
||||||
(char-equal (string-to-char frag-attr) ?\())
|
(mapcar*
|
||||||
(mapcar*
|
(lambda (item frag)
|
||||||
(lambda (item frag)
|
"Append reveal's fragment attribute to item's
|
||||||
"Overwrite item's `:checkbox' property with reveal's
|
`:attr_html' property."
|
||||||
fragment attribute."
|
(and (not (string= frag "none"))
|
||||||
(and (not (string= frag "none"))
|
(org-reveal--update-attr-html item frag))
|
||||||
(org-element-put-property
|
;; Return nil.
|
||||||
item :checkbox
|
nil)
|
||||||
(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 (org-reveal--update-attr-html elem frag-attr))))
|
||||||
(car (read-from-string frag-attr))))
|
|
||||||
(t
|
|
||||||
;; Convert reveal's fragment attribute to HTML attribute.
|
|
||||||
(let ((attr-html (org-element-property :attr_html elem)))
|
|
||||||
(push
|
|
||||||
(cond ((string= frag-attr t) ":class fragment")
|
|
||||||
(t (concat ":class fragment " frag-attr)))
|
|
||||||
attr-html)
|
|
||||||
(org-element-put-property elem :attr_html attr-html)))))
|
|
||||||
elem))
|
elem))
|
||||||
|
|
||||||
(defun org-reveal-append-frag-index (elem)
|
(defun org-reveal-append-frag-index (elem)
|
||||||
|
|
Loading…
Reference in New Issue