/ OPTIONS PROCESSING / strip IDs the same way revealjs does (remove when hakimel/reveal.js#1230 is fixed) - _id = id.gsub(/[^a-zA-Z0-9\-\_\:\.]/, '') / hide slides on %conceal, %notitle and named "!" - titleless = (title = self.title) == '!' - hide_title = (titleless || (option? :notitle) || (option? :conceal)) - vertical_slides = find_by(context: :section) {|section| section.level == 2 } / extracting block image attributes to find an image to use as a / background_image attribute - data_background_image, data_background_size, data_background_repeat, data_background_transition = nil / process the first image block in the current section that acts as a background - section_images = blocks.map do |block| - if (ctx = block.context) == :image - ['background', 'canvas'].include?(block.attr 1) ? block : [] - elsif ctx == :section - [] - else - block.find_by(context: :image) {|image| ['background', 'canvas'].include?(image.attr 1) } || [] - if (bg_image = section_images.flatten.first) - data_background_image = image_uri(bg_image.attr 'target') / make sure no crash on nil and default values make sense - data_background_size = bg_image.attr 'size' - data_background_repeat = bg_image.attr 'repeat' - data_background_transition = bg_image.attr 'transition' / background-image section attribute overrides the image one - if attr? 'background-image' - data_background_image = image_uri(attr 'background-image') - if attr? 'background-color' - data_background_color = attr 'background-color' / RENDERING / render parent section of vertical slides set - if @level == 1 && !vertical_slides.empty? section / TODO: try to get rid of duplication w/ standalone slide section section(id=(titleless ? nil : _id) class=roles data-transition=(attr 'transition') data-transition-speed=(attr 'transition-speed') data-background-color=data_background_color data-background-image=data_background_image data-background-size=(data_background_size || attr('background-size')) data-background-repeat=(data_background_repeat || attr('background-repeat')) data-background-transition=(data_background_transition || attr('background-transition')) data-background-iframe=(attr "background-iframe") data-background-video=(attr "background-video") data-background-video-loop=((attr? 'background-video-loop') || (option? 'loop')) data-background-video-muted=((attr? 'background-video-muted') || (option? 'muted')) data-state=(attr 'state')) - unless hide_title h2=title - (blocks - vertical_slides).each do |block| =block.convert - vertical_slides.each do |subsection| =subsection.convert / render standalone slides (or vertical slide subsection) - else - if @level >= 3 / dynamic tags which maps with level *{tag: %(h#{@level})} =title =content.chomp - else section(id=(titleless ? nil : _id) class=roles data-transition=(attr 'transition') data-transition-speed=(attr 'transition-speed') data-background-color=data_background_color data-background-image=data_background_image data-background-size=(data_background_size || attr('background-size')) data-background-repeat=(data_background_repeat || attr('background-repeat')) data-background-transition=(data_background_transition || attr('background-transition')) data-background-iframe=(attr "background-iframe") data-background-video=(attr "background-video") data-background-video-loop=((attr? 'background-video-loop') || (option? 'loop')) data-background-video-muted=((attr? 'background-video-muted') || (option? 'muted')) data-state=(attr 'state')) - unless hide_title h2=title =content.chomp