mirror of https://github.com/yjwen/org-reveal.git
Re-orginize codes.
This commit is contained in:
parent
2f8ee48881
commit
24bd4e484a
72
ox-reveal.el
72
ox-reveal.el
|
@ -285,6 +285,28 @@ can be include."
|
||||||
(defun if-format (fmt val)
|
(defun if-format (fmt val)
|
||||||
(if val (format fmt val) ""))
|
(if val (format fmt val) ""))
|
||||||
|
|
||||||
|
(defun org-reveal-attrs-list (attrs)
|
||||||
|
"Generate an HTML attribute list string from the list
|
||||||
|
ATTRS. ATTRS is expected to be a list of key-value pairs, ((key0
|
||||||
|
. value0) (key1 . value1) ...), and for each pair of none-nil
|
||||||
|
value, an HTML attribute statement key=\"value\" is inserted into
|
||||||
|
the result string."
|
||||||
|
(mapconcat
|
||||||
|
(lambda (elem)
|
||||||
|
(let ((key (car elem))
|
||||||
|
(value (car (cdr elem))))
|
||||||
|
(if value (format " %s=\"%s\"" key value))))
|
||||||
|
attrs ""))
|
||||||
|
(defun org-reveal-tag (tagname attrs content &optional sep)
|
||||||
|
"Generate an HTML tag of form <TAGNAME ATTRS>CONTENT</TAGNAME>. If
|
||||||
|
SEP is given, then the CONTENT is enclosed by SEP, otherwise it is enclosed by
|
||||||
|
a '\n'"
|
||||||
|
(let ((sep_ (or sep "\n")))
|
||||||
|
(format "<%s%s>%s%s%s</%s>"
|
||||||
|
tagname ; The leading tagname.
|
||||||
|
(org-reveal-attrs-list attrs)
|
||||||
|
sep_ content sep_ tagname)))
|
||||||
|
|
||||||
(defun frag-class (frag)
|
(defun frag-class (frag)
|
||||||
;; Return proper HTML string description of fragment style.
|
;; Return proper HTML string description of fragment style.
|
||||||
(cond
|
(cond
|
||||||
|
@ -294,14 +316,12 @@ can be include."
|
||||||
|
|
||||||
(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.
|
||||||
CONTENTS is nil. NFO is a plist holding contextual information."
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
||||||
(let ((block-type (org-element-property :type export-block))
|
(let ((block-type (org-element-property :type export-block))
|
||||||
(block-string (org-element-property :value export-block)))
|
(block-string (org-element-property :value export-block)))
|
||||||
(cond ((string= block-type "NOTES")
|
(cond ((string= block-type "NOTES")
|
||||||
(concat
|
(org-reveal-tag 'aside '(('class . 'notes))
|
||||||
"<aside class=\"notes\">\n"
|
(org-export-string-as block-string 'html 'body-only)))
|
||||||
(org-export-string-as block-string 'html 'body-only)
|
|
||||||
"</aside>"))
|
|
||||||
((string= block-type "HTML")
|
((string= block-type "HTML")
|
||||||
(org-remove-indentation block-string)))))
|
(org-remove-indentation block-string)))))
|
||||||
|
|
||||||
|
@ -347,7 +367,7 @@ holding contextual information."
|
||||||
(org-html-end-plain-list type)))))
|
(org-html-end-plain-list type)))))
|
||||||
;; Case 3. Standard headline. Export it as a section.
|
;; Case 3. Standard headline. Export it as a section.
|
||||||
(t
|
(t
|
||||||
(let* ((level1 (+ level (1- org-html-toplevel-hlevel)))
|
(let* ((level1 (format "h%d" (+ level (1- org-html-toplevel-hlevel))))
|
||||||
(hlevel (org-reveal--get-hlevel info))
|
(hlevel (org-reveal--get-hlevel info))
|
||||||
(first-content (car (org-element-contents headline))))
|
(first-content (car (org-element-contents headline))))
|
||||||
(concat
|
(concat
|
||||||
|
@ -360,25 +380,29 @@ holding contextual information."
|
||||||
;; into vertical ones.
|
;; into vertical ones.
|
||||||
"<section>\n")
|
"<section>\n")
|
||||||
;; Start a new slide.
|
;; Start a new slide.
|
||||||
(format "<section id=\"%s\" %s%s%s%s%s%s%s>\n"
|
(format "<section%s%s>\n"
|
||||||
(or (org-element-property :CUSTOM_ID headline)
|
(org-reveal-attrs-list
|
||||||
(concat "sec-" (mapconcat 'number-to-string
|
`(("id" ,(or (org-element-property :CUSTOM_ID headline)
|
||||||
(org-export-get-headline-number headline info)
|
(concat "sec-"
|
||||||
"-")))
|
(mapconcat 'number-to-string
|
||||||
(if-format " data-state=\"%s\"" (org-element-property :REVEAL_DATA_STATE headline))
|
(org-export-get-headline-number headline info)
|
||||||
(if-format " data-transition=\"%s\"" (org-element-property :REVEAL_DATA_TRANSITION headline))
|
"-"))))
|
||||||
(if-format " data-background=\"%s\"" (org-element-property :REVEAL_BACKGROUND headline))
|
("data-state" ,(org-element-property :REVEAL_DATA_STATE headline))
|
||||||
(if-format " data-background-size=\"%s\"" (org-element-property :REVEAL_BACKGROUND_SIZE headline))
|
("data-transition" ,(org-element-property :REVEAL_DATA_TRANSITION headline))
|
||||||
(if-format " data-background-repeat=\"%s\"" (org-element-property :REVEAL_BACKGROUND_REPEAT headline))
|
("data-background" ,(org-element-property :REVEAL_BACKGROUND headline))
|
||||||
(if-format " data-background-transition=\"%s\"" (org-element-property :REVEAL_BACKGROUND_TRANS headline))
|
("data-background-size" ,(org-element-property :REVEAL_BACKGROUND_SIZE headline))
|
||||||
(if-format " %s" (org-element-property :REVEAL_EXTRA_ATTR headline)))
|
("data-background-repeat" ,(org-element-property :REVEAL_BACKGROUND_REPEAT headline))
|
||||||
|
("data-background-transition" ,(org-element-property :REVEAL_BACKGROUND_TRANS headline))))
|
||||||
|
(let ((extra-attrs (org-element-property :REVEAL_EXTRA_ATTR headline)))
|
||||||
|
(if extra-attrs (format " %s" extra-attrs) "")))
|
||||||
|
"\n"
|
||||||
;; The HTML content of this headline.
|
;; The HTML content of this headline.
|
||||||
(format "\n<h%d%s>%s</h%d>\n"
|
(org-reveal-tag level1 ;;"\n<h%d%s>%s</h%d>\n"
|
||||||
level1
|
(let ((fragment (org-element-property :REVEAL-FRAG headline)))
|
||||||
(if-format " class=\"fragment %s\""
|
(if fragment `(("class" ,(concat "fragment " fragment)))))
|
||||||
(org-element-property :REVEAL-FRAG headline))
|
full-text
|
||||||
full-text
|
"")
|
||||||
level1)
|
"\n"
|
||||||
;; When there is no section, pretend there is an empty
|
;; When there is no section, pretend there is an empty
|
||||||
;; one to get the correct <div class="outline- ...>
|
;; one to get the correct <div class="outline- ...>
|
||||||
;; which is needed by `org-info.js'.
|
;; which is needed by `org-info.js'.
|
||||||
|
|
Loading…
Reference in New Issue