module Slideshow::DeckFilter

Public Instance Methods

add_slide_directive_before_h1( content ) click to toggle source

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'>

# File lib/slideshow/models/deck.rb, line 24
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 = 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
add_slide_directive_before_h2( content ) click to toggle source
# File lib/slideshow/models/deck.rb, line 41
def add_slide_directive_before_h2( content )

  slide_count = 0

  content = 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_for_hr( content ) click to toggle source
# File lib/slideshow/models/deck.rb, line 56
def add_slide_directive_for_hr( content )

  slide_count = 0

  ##  replace <hr> or <hr /> with slide directive/comment
  ##  note: hr gets **replaced/removed**

  content = content.gsub( /<hr(\s*\/)?>/ ) do |match|
    slide_count += 1
    "\n<!-- _S9SLIDE_ -->\n"
  end
  
  puts "  Adding #{slide_count} slide breaks (using hr rule)..."
  
  content
end