Module: Slideshow::SlideFilter
- Included in:
- Gen
- Defined in:
- lib/slideshow/filters/slide_filter.rb
Instance Method Summary collapse
- #add_slide_directive_before_div_h1(content) ⇒ Object
-
#add_slide_directive_before_h1(content) ⇒ Object
add slide directive before h1 (tells slideshow gem where to break slides).
- #add_slide_directive_before_h2(content) ⇒ Object
- #takahashi_slide_breaks(content) ⇒ Object
Instance Method Details
#add_slide_directive_before_div_h1(content) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/slideshow/filters/slide_filter.rb', line 93 def ( content ) = 0 content.gsub!( /<div[^>]*>\s*<h1/ ) do |match| += 1 "\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}" end puts " Adding #{slide_count} slide breaks (using div_h1 rule)..." content end |
#add_slide_directive_before_h1(content) ⇒ Object
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’>
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/slideshow/filters/slide_filter.rb', line 49 def ( content ) # mark h1 for getting wrapped into slide divs # note: use just <h1 since some processors add ids e.g. <h1 id='x'> = 0 content.gsub!( /<h1/ ) do |match| += 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) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/slideshow/filters/slide_filter.rb', line 66 def ( content ) = 0 content.gsub!( /<h2/ ) do |match| += 1 "\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}" end puts " Adding #{slide_count} slide breaks (using h2 rule)..." content end |
#takahashi_slide_breaks(content) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/slideshow/filters/slide_filter.rb', line 6 def ( content ) inline_count = 0 line_count = 0 ########################### ## allows one // two // three content.gsub!( /\b[ ]+\/{2}[ ]+\b/) do |match| inline_count += 1 ## todo: use slide('') directive helper? "\n\n<!-- _S9SLIDE_ -->\n\n" end ############################ ## allows ## ## one ## // ## two ## // ## three content.gsub!( /^[ ]*\/{2}[ ]*$/ ) do |match| line_count += 1 ## todo: use slide('') directive helper? "\n\n<!-- _S9SLIDE_ -->\n\n" end puts " Adding #{inline_count+line_count} takahashi slide breaks (#{inline_count} //-inline, #{line_count} //-line)..." content end |