Sha256: dcfe573a0f495d7fcc077ee848fbae65c66d88ec73dde0944a3ab88029a36504

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

# encoding: utf-8
module Slideshow
  module SlideFilter


# add slide directive before h1 (tells slideshow gem where to break slides)
#
# e.g. changes:
# <h1 id='optional' class='optional'>
#  to
#  html comment -> _S9SLIDE_ (note: rdoc can't handle html comments?) 
# <h1 id='optional' class='optional'>

def add_slide_directive_before_h1( content )

  # mark h1 for getting wrapped into slide divs
  # note: use just <h1 since some processors add ids e.g. <h1 id='x'>

  slide_count = 0

  content.gsub!( /<h1/ ) do |match|
    slide_count += 1
    "\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
  end
  
  puts "  Adding #{slide_count} slide breaks (using h1 rule)..."
  
  content
end

def add_slide_directive_before_h2( content )

  slide_count = 0

  content.gsub!( /<h2/ ) do |match|
    slide_count += 1
    "\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
  end
  
  puts "  Adding #{slide_count} slide breaks (using h2 rule)..."
  
  content
end



# add slide directive before div h1 (for pandoc-generated html)
#
# e.g. changes:
# <div id='header'>
# <h1 id='optional' class='optional'>
#  to
#  html comment -> _S9SLIDE_ 
# <div id='header'>
# <h1 id='optional' class='optional'>


def add_slide_directive_before_div_h1( content )

  slide_count = 0

  content.gsub!( /<div[^>]*>\s*<h1/ ) do |match|
    slide_count += 1
    "\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}" 
  end

  puts "  Adding #{slide_count} slide breaks (using div_h1 rule)..."

  content
end

  
end  # module SlideFilter
end # module Slideshow

class Slideshow::Gen
  include Slideshow::SlideFilter
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
slideshow-1.2.1 lib/slideshow/filters/slide_filter.rb
slideshow-1.2.0 lib/slideshow/filters/slide_filter.rb
slideshow-1.2.0.beta5 lib/slideshow/filters/slide_filter.rb
slideshow-1.2.0.beta4 lib/slideshow/filters/slide_filter.rb
slideshow-1.2.0.beta3 lib/slideshow/filters/slide_filter.rb
slideshow-1.2.0.beta2 lib/slideshow/filters/slide_filter.rb
slideshow-1.2.0.beta1 lib/slideshow/filters/slide_filter.rb
slideshow-1.1.0 lib/slideshow/filters/slide_filter.rb