Sha256: 553c6fdad5d52004a0ffb94100c7e1003471d43f106b07e05223959bfe5b0f79

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 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

# 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

14 entries across 14 versions & 1 rubygems

Version Path
slideshow-1.1.0.beta8 lib/slideshow/filters/slide_filter.rb
slideshow-1.1.0.beta7 lib/slideshow/filters/slide_filter.rb
slideshow-1.1.0.beta6 lib/slideshow/filters/slide_filter.rb
slideshow-1.1.0.beta5 lib/slideshow/filters/slide_filter.rb
slideshow-1.1.0.beta4 lib/slideshow/filters/slide_filter.rb
slideshow-1.1.0.beta3 lib/slideshow/filters/slide_filter.rb
slideshow-1.1.0.beta2 lib/slideshow/filters/slide_filter.rb
slideshow-1.1.0.beta1 lib/slideshow/filters/slide_filter.rb
slideshow-1.0.5 lib/slideshow/filters/slide_filter.rb
slideshow-1.0.4 lib/slideshow/filters/slide_filter.rb
slideshow-1.0.3 lib/slideshow/filters/slide_filter.rb
slideshow-1.0.2 lib/slideshow/filters/slide_filter.rb
slideshow-1.0.1 lib/slideshow/filters/slide_filter.rb
slideshow-1.0.0 lib/slideshow/filters/slide_filter.rb