mirror of https://github.com/yjwen/org-reveal.git
Fixed #345. Re-generate section tag for split slide.
This commit is contained in:
parent
ece13022d1
commit
83b8d9f231
211
ox-reveal.el
211
ox-reveal.el
|
@ -386,9 +386,6 @@ BEFORE the plugins that depend on them."
|
||||||
:group 'org-export-reveal
|
:group 'org-export-reveal
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
(defvar org-reveal--last-slide-section-tag ""
|
|
||||||
"Variable to cache the section tag from the last slide. ")
|
|
||||||
|
|
||||||
(defun if-format (fmt val)
|
(defun if-format (fmt val)
|
||||||
(if val (format fmt val) ""))
|
(if val (format fmt val) ""))
|
||||||
|
|
||||||
|
@ -423,6 +420,36 @@ exporter."
|
||||||
(format "<aside class=\"notes\">\n%s\n</aside>\n" contents)
|
(format "<aside class=\"notes\">\n%s\n</aside>\n" contents)
|
||||||
(org-html-special-block special-block contents info))))
|
(org-html-special-block special-block contents info))))
|
||||||
|
|
||||||
|
(defun org-reveal-slide-section-tag (headline info for-split)
|
||||||
|
"Generate the <section> tag for a slide."
|
||||||
|
(let* ((preferred-id (or (org-element-property :CUSTOM_ID headline)
|
||||||
|
(org-export-get-reference headline info)))
|
||||||
|
(default-slide-background (plist-get info :reveal-default-slide-background))
|
||||||
|
(default-slide-background-size (plist-get info :reveal-default-slide-background-size))
|
||||||
|
(default-slide-background-position (plist-get info :reveal-default-slide-background-position))
|
||||||
|
(default-slide-background-repeat (plist-get info :reveal-default-slide-background-repeat))
|
||||||
|
(default-slide-background-transition (plist-get info :reveal-default-slide-background-transition))
|
||||||
|
)
|
||||||
|
(format "<section %s%s>\n"
|
||||||
|
(org-html--make-attribute-string
|
||||||
|
`(:id ,(format "slide-%s%s" preferred-id
|
||||||
|
(if for-split "-split" ""))
|
||||||
|
:class ,(org-element-property :HTML_CONTAINER_CLASS headline)
|
||||||
|
:data-transition ,(org-element-property :REVEAL_DATA_TRANSITION headline)
|
||||||
|
:data-state ,(org-element-property :REVEAL_DATA_STATE headline)
|
||||||
|
:data-background ,(or (org-element-property :REVEAL_BACKGROUND headline)
|
||||||
|
default-slide-background)
|
||||||
|
:data-background-size ,(or (org-element-property :REVEAL_BACKGROUND_SIZE headline)
|
||||||
|
default-slide-background-size)
|
||||||
|
:data-background-position ,(or (org-element-property :REVEAL_BACKGROUND_POSITION headline)
|
||||||
|
default-slide-background-position)
|
||||||
|
:data-background-repeat ,(or (org-element-property :REVEAL_BACKGROUND_REPEAT headline)
|
||||||
|
default-slide-background-repeat)
|
||||||
|
:data-background-transition ,(or (org-element-property :REVEAL_BACKGROUND_TRANS headline)
|
||||||
|
default-slide-background-transition)))
|
||||||
|
(let ((extra-attrs (org-element-property :REVEAL_EXTRA_ATTR headline)))
|
||||||
|
(if-format " %s" extra-attrs)))))
|
||||||
|
|
||||||
;; Copied from org-html-headline and modified to embed org-reveal
|
;; Copied from org-html-headline and modified to embed org-reveal
|
||||||
;; specific attributes.
|
;; specific attributes.
|
||||||
(defun org-reveal-headline (headline contents info)
|
(defun org-reveal-headline (headline contents info)
|
||||||
|
@ -438,87 +465,56 @@ holding contextual information."
|
||||||
(section-number (mapconcat #'number-to-string
|
(section-number (mapconcat #'number-to-string
|
||||||
(org-export-get-headline-number headline info)
|
(org-export-get-headline-number headline info)
|
||||||
"-"))
|
"-"))
|
||||||
(preferred-id (or (org-element-property :CUSTOM_ID headline)
|
|
||||||
(org-export-get-reference headline info)))
|
|
||||||
(hlevel (org-reveal--get-hlevel info))
|
(hlevel (org-reveal--get-hlevel info))
|
||||||
(header (plist-get info :reveal-slide-header))
|
(header (plist-get info :reveal-slide-header))
|
||||||
(header-div (when header (format "<div class=\"slide-header\">%s</div>\n" header)))
|
(header-div (when header (format "<div class=\"slide-header\">%s</div>\n" header)))
|
||||||
(footer (plist-get info :reveal-slide-footer))
|
(footer (plist-get info :reveal-slide-footer))
|
||||||
(footer-div (when footer (format "<div class=\"slide-footer\">%s</div>\n" footer)))
|
(footer-div (when footer (format "<div class=\"slide-footer\">%s</div>\n" footer)))
|
||||||
(first-sibling (org-export-first-sibling-p headline info))
|
(first-sibling (org-export-first-sibling-p headline info))
|
||||||
(last-sibling (org-export-last-sibling-p headline info))
|
(last-sibling (org-export-last-sibling-p headline info)))
|
||||||
(default-slide-background (plist-get info :reveal-default-slide-background))
|
(concat
|
||||||
(default-slide-background-size (plist-get info :reveal-default-slide-background-size))
|
(if (or (/= level 1) (not first-sibling))
|
||||||
(default-slide-background-position (plist-get info :reveal-default-slide-background-position))
|
;; Not the first heading. Close previou slide.
|
||||||
(default-slide-background-repeat (plist-get info :reveal-default-slide-background-repeat))
|
(concat
|
||||||
(default-slide-background-transition (plist-get info :reveal-default-slide-background-transition))
|
;; Slide footer if any
|
||||||
(slide-section-tag (format "<section %s%s>\n"
|
footer-div
|
||||||
(org-html--make-attribute-string
|
;; Close previous slide
|
||||||
`(:id ,(format "slide-%s" preferred-id)
|
"</section>\n"
|
||||||
:class ,(org-element-property :HTML_CONTAINER_CLASS headline)
|
(if (<= level hlevel)
|
||||||
:data-transition ,(org-element-property :REVEAL_DATA_TRANSITION headline)
|
;; Close previous vertical slide group.
|
||||||
:data-state ,(org-element-property :REVEAL_DATA_STATE headline)
|
"</section>\n")))
|
||||||
:data-background ,(or (org-element-property :REVEAL_BACKGROUND headline)
|
(if (<= level hlevel)
|
||||||
default-slide-background)
|
;; Add an extra "<section>" to group following slides
|
||||||
:data-background-size ,(or (org-element-property :REVEAL_BACKGROUND_SIZE headline)
|
;; into vertical slide group. Transition override
|
||||||
default-slide-background-size)
|
;; attributes are attached at this level, too.
|
||||||
:data-background-position ,(or (org-element-property :REVEAL_BACKGROUND_POSITION headline)
|
(let ((attrs
|
||||||
default-slide-background-position)
|
(org-html--make-attribute-string
|
||||||
:data-background-repeat ,(or (org-element-property :REVEAL_BACKGROUND_REPEAT headline)
|
`(:data-transition ,(org-element-property :REVEAL_DATA_TRANSITION headline)))))
|
||||||
default-slide-background-repeat)
|
(if (string= attrs "")
|
||||||
:data-background-transition ,(or (org-element-property :REVEAL_BACKGROUND_TRANS headline)
|
"<section>\n"
|
||||||
default-slide-background-transition)))
|
(format "<section %s>\n" attrs))))
|
||||||
(let ((extra-attrs (org-element-property :REVEAL_EXTRA_ATTR headline)))
|
;; Start a new slide.
|
||||||
(if extra-attrs (format " %s" extra-attrs) ""))))
|
(org-reveal-slide-section-tag headline info nil)
|
||||||
(ret (concat
|
;; Slide header if any.
|
||||||
(if (or (/= level 1) (not first-sibling))
|
header-div
|
||||||
;; Not the first heading. Close previou slide.
|
;; The HTML content of the headline
|
||||||
(concat
|
;; Strip the <div> tags, if any
|
||||||
;; Slide footer if any
|
(let ((html (org-html-headline headline contents info)))
|
||||||
footer-div
|
(if (string-prefix-p "<div" html)
|
||||||
;; Close previous slide
|
;; Remove the first <div> and the last </div> tags from html
|
||||||
"</section>\n"
|
(concat "<"
|
||||||
(if (<= level hlevel)
|
(mapconcat 'identity
|
||||||
;; Close previous vertical slide group.
|
(butlast (cdr (split-string html "<" t)))
|
||||||
"</section>\n")))
|
"<"))
|
||||||
(if (<= level hlevel)
|
;; Return the HTML content unchanged
|
||||||
;; Add an extra "<section>" to group following slides
|
html))
|
||||||
;; into vertical slide group. Transition override
|
(if (and (= level 1)
|
||||||
;; attributes are attached at this level, too.
|
(org-export-last-sibling-p headline info))
|
||||||
(let ((attrs
|
;; Last head 1. Close all slides.
|
||||||
(org-html--make-attribute-string
|
(concat
|
||||||
`(:data-transition ,(org-element-property :REVEAL_DATA_TRANSITION headline)))))
|
;; Slide footer if any
|
||||||
(if (string= attrs "")
|
footer-div
|
||||||
"<section>\n"
|
"</section>\n</section>\n")))))))
|
||||||
(format "<section %s>\n" attrs))))
|
|
||||||
;; Start a new slide.
|
|
||||||
(prog1
|
|
||||||
slide-section-tag
|
|
||||||
;; Cache the current slide's section tag, except the id attr
|
|
||||||
(setq org-reveal--last-slide-section-tag
|
|
||||||
(replace-regexp-in-string "id\\s-*=\\s-*[\][\"].*?[\][\"]"
|
|
||||||
"" slide-section-tag)))
|
|
||||||
;; Slide header if any.
|
|
||||||
header-div
|
|
||||||
;; The HTML content of the headline
|
|
||||||
;; Strip the <div> tags, if any
|
|
||||||
(let ((html (org-html-headline headline contents info)))
|
|
||||||
(if (string-prefix-p "<div" html)
|
|
||||||
;; Remove the first <div> and the last </div> tags from html
|
|
||||||
(concat "<"
|
|
||||||
(mapconcat 'identity
|
|
||||||
(butlast (cdr (split-string html "<" t)))
|
|
||||||
"<"))
|
|
||||||
;; Return the HTML content unchanged
|
|
||||||
html))
|
|
||||||
(if (and (= level 1)
|
|
||||||
(org-export-last-sibling-p headline info))
|
|
||||||
;; Last head 1. Close all slides.
|
|
||||||
(concat
|
|
||||||
;; Slide footer if any
|
|
||||||
footer-div
|
|
||||||
"</section>\n</section>\n")))))
|
|
||||||
ret))))
|
|
||||||
|
|
||||||
(defgroup org-export-reveal nil
|
(defgroup org-export-reveal nil
|
||||||
"Options for exporting Orgmode files to reveal.js HTML pressentations."
|
"Options for exporting Orgmode files to reveal.js HTML pressentations."
|
||||||
|
@ -791,35 +787,36 @@ holding export options."
|
||||||
"Return HTML tags or perform SIDE EFFECT according to key.
|
"Return HTML tags or perform SIDE EFFECT according to key.
|
||||||
Use the previous section tag as the tag of the split section. "
|
Use the previous section tag as the tag of the split section. "
|
||||||
(case (intern key)
|
(case (intern key)
|
||||||
(split (format "</section>%s"
|
(split
|
||||||
(concat
|
(let ((headline (org-element-property
|
||||||
org-reveal--last-slide-section-tag
|
:parent
|
||||||
(and value
|
(org-element-property
|
||||||
(string= value "t")
|
:parent
|
||||||
;; Add a title for the split slide
|
keyword))))
|
||||||
;; Copy from `org-html-headline' and modified.
|
(concat
|
||||||
(let* ((headline (org-element-property
|
"</section>\n" ;; Close the previous section and start a new one.
|
||||||
:parent
|
(org-reveal-slide-section-tag headline info t)
|
||||||
(org-element-property
|
(and value
|
||||||
:parent
|
(string= value "t")
|
||||||
keyword)))
|
;; Add a title for the split slide
|
||||||
(title (org-export-data
|
;; Copy from `org-html-headline' and modified.
|
||||||
(org-element-property :title headline)
|
(let* ((title (org-export-data
|
||||||
info))
|
(org-element-property :title headline)
|
||||||
(level (+ (org-export-get-relative-level headline info)
|
info))
|
||||||
(1- (plist-get info :html-toplevel-hlevel))))
|
(level (+ (org-export-get-relative-level headline info)
|
||||||
(numberedp (org-export-numbered-headline-p headline info))
|
(1- (plist-get info :html-toplevel-hlevel))))
|
||||||
(numbers (org-export-get-headline-number headline info)))
|
(numberedp (org-export-numbered-headline-p headline info))
|
||||||
(format "\n<h%d>%s</h%d>"
|
(numbers (org-export-get-headline-number headline info)))
|
||||||
level
|
(format "\n<h%d>%s</h%d>"
|
||||||
(concat
|
level
|
||||||
(and numberedp
|
(concat
|
||||||
(format
|
(and numberedp
|
||||||
"<span class=\"section-number-%d\">%s</span> "
|
(format
|
||||||
level
|
"<span class=\"section-number-%d\">%s</span> "
|
||||||
(mapconcat #'number-to-string numbers ".")))
|
level
|
||||||
title)
|
(mapconcat #'number-to-string numbers ".")))
|
||||||
level))))))))
|
title)
|
||||||
|
level))))))))
|
||||||
|
|
||||||
(defun org-reveal-parse-keyword-value (keyward value info)
|
(defun org-reveal-parse-keyword-value (keyward value info)
|
||||||
"According to the value content, return HTML tags to split slides."
|
"According to the value content, return HTML tags to split slides."
|
||||||
|
|
Loading…
Reference in New Issue