Class: Codex::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/codex/content.rb

Constant Summary collapse

START_SLIDE =
%{<div class="slide">\n}
END_SLIDE =
%{</div>\n}
BETWEEN_SLIDES =
END_SLIDE + "\n" + START_SLIDE

Instance Method Summary collapse

Constructor Details

#initialize(original) ⇒ Content

Returns a new instance of Content.



8
9
10
# File 'lib/codex/content.rb', line 8

def initialize(original)
  @original = original.sub(/__END__.*/m, '').gsub(/__SKIP__.*?__ENDSKIP__/m, '')
end

Instance Method Details

#split_into_slides(textile) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/codex/content.rb', line 18

def split_into_slides(textile)
  result = []
  slides = textile.split(/^h1/).each do |slide|
    unless slide.empty?
      result << START_SLIDE << "\nh1" << slide << END_SLIDE
    end
  end
  result.join
end

#to_htmlObject



12
13
14
15
16
# File 'lib/codex/content.rb', line 12

def to_html
  textile = Codex::Filters.instance.filter_all(@original)
  content = split_into_slides(textile)
  html = RedCloth.new(content).to_html
end