Support setting default slide properties

Below comment keywords are now supported to set the default properties
    for non-title slides

    #+REVEAL_DEFAULT_SLIDE_BACKGROUND
    #+REVEAL_DEFAULT_SLIDE_BACKGROUND_SIZE
    #+REVEAL_DEFAULT_SLIDE_BACKGROUND_POSITION
    #+REVEAL_DEFAULT_SLIDE_BACKGROUND_REPEAT
    #+REVEAL_DEFAULT_SLIDE_BACKGROUND_TRANSITION

Fix the section tag for slides created by splitting using "#+REVEAL:
split". If the parent slide from which the new slide got split off had a
background, the new slide would get no background. That's because
splitting a slide did not automatically copy the parent slide's section
tag metadata to the new slide.

This commit fixes that bug too.
This commit is contained in:
Kaushal Modi 2016-09-14 15:17:13 -04:00
parent b64ba125d3
commit 85e23eb4c3
1 changed files with 83 additions and 57 deletions

View File

@ -69,6 +69,11 @@
(:reveal-title-slide-background-position "REVEAL_TITLE_SLIDE_BACKGROUND_POSITION" nil nil t) (:reveal-title-slide-background-position "REVEAL_TITLE_SLIDE_BACKGROUND_POSITION" nil nil t)
(:reveal-title-slide-background-repeat "REVEAL_TITLE_SLIDE_BACKGROUND_REPEAT" nil nil t) (:reveal-title-slide-background-repeat "REVEAL_TITLE_SLIDE_BACKGROUND_REPEAT" nil nil t)
(:reveal-title-slide-background-transition "REVEAL_TITLE_SLIDE_BACKGROUND_TRANSITION" nil nil t) (:reveal-title-slide-background-transition "REVEAL_TITLE_SLIDE_BACKGROUND_TRANSITION" nil nil t)
(:reveal-default-slide-background "REVEAL_DEFAULT_SLIDE_BACKGROUND" nil nil t)
(:reveal-default-slide-background-size "REVEAL_DEFAULT_SLIDE_BACKGROUND_SIZE" nil nil t)
(:reveal-default-slide-background-position "REVEAL_DEFAULT_SLIDE_BACKGROUND_POSITION" nil nil t)
(:reveal-default-slide-background-repeat "REVEAL_DEFAULT_SLIDE_BACKGROUND_REPEAT" nil nil t)
(:reveal-default-slide-background-transition "REVEAL_DEFAULT_SLIDE_BACKGROUND_TRANSITION" nil nil t)
(:reveal-mathjax-url "REVEAL_MATHJAX_URL" nil org-reveal-mathjax-url t) (:reveal-mathjax-url "REVEAL_MATHJAX_URL" nil org-reveal-mathjax-url t)
(:reveal-preamble "REVEAL_PREAMBLE" nil org-reveal-preamble t) (:reveal-preamble "REVEAL_PREAMBLE" nil org-reveal-preamble t)
(:reveal-head-preamble "REVEAL_HEAD_PREAMBLE" nil org-reveal-head-preamble newline) (:reveal-head-preamble "REVEAL_HEAD_PREAMBLE" nil org-reveal-head-preamble newline)
@ -343,6 +348,9 @@ content."
: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) ""))
@ -398,8 +406,30 @@ holding contextual information."
(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))
(concat (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))
(slide-section-tag (format "<section %s%s>\n"
(org-html--make-attribute-string
`(:id ,(format "slide-%s" preferred-id)
: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 extra-attrs (format " %s" extra-attrs) ""))))
(ret (concat
(if (or (/= level 1) (not first-sibling)) (if (or (/= level 1) (not first-sibling))
;; Not the first heading. Close previou slide. ;; Not the first heading. Close previou slide.
(concat (concat
@ -421,18 +451,12 @@ holding contextual information."
"<section>\n" "<section>\n"
(format "<section %s>\n" attrs)))) (format "<section %s>\n" attrs))))
;; Start a new slide. ;; Start a new slide.
(format "<section %s%s>\n" (prog1
(org-html--make-attribute-string slide-section-tag
`(:id ,(format "slide-%s" preferred-id) ;; Cache the current slide's section tag, except the id attr
:data-transition ,(org-element-property :REVEAL_DATA_TRANSITION headline) (setq org-reveal--last-slide-section-tag
:data-state ,(org-element-property :REVEAL_DATA_STATE headline) (replace-regexp-in-string "id\\s-*=\\s-*[\][\"].*?[\][\"]"
:data-background ,(org-element-property :REVEAL_BACKGROUND headline) "" slide-section-tag)))
:data-background-size ,(org-element-property :REVEAL_BACKGROUND_SIZE headline)
:data-background-position ,(org-element-property :REVEAL_BACKGROUND_POSITION 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) "")))
;; Slide header if any. ;; Slide header if any.
header-div header-div
;; The HTML content of the headline ;; The HTML content of the headline
@ -452,7 +476,8 @@ holding contextual information."
(concat (concat
;; Slide footer if any ;; Slide footer if any
footer-div footer-div
"</section>\n</section>\n"))))))) "</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."
@ -713,9 +738,10 @@ holding export options."
contents)) contents))
(defun org-reveal-parse-token (key &optional value) (defun org-reveal-parse-token (key &optional value)
"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. "
(case (intern key) (case (intern key)
(split "</section>\n<section>"))) (split (format "</section>\n%s" org-reveal--last-slide-section-tag ""))))
(defun org-reveal-parse-keyword-value (value) (defun org-reveal-parse-keyword-value (value)
"According to the value content, return HTML tags to split slides." "According to the value content, return HTML tags to split slides."