Class: Revealize::MarkdownSlide::Slide

Inherits:
Struct
  • Object
show all
Defined in:
lib/revealize/slide.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#raw_contentObject

Returns the value of attribute raw_content

Returns:

  • (Object)

    the current value of raw_content



17
18
19
# File 'lib/revealize/slide.rb', line 17

def raw_content
  @raw_content
end

#rendered_markdownObject (readonly)

Returns the value of attribute rendered_markdown.



18
19
20
# File 'lib/revealize/slide.rb', line 18

def rendered_markdown
  @rendered_markdown
end

Instance Method Details

#content_without_preambleObject



28
29
30
31
32
33
34
# File 'lib/revealize/slide.rb', line 28

def content_without_preamble
  return raw_content unless raw_content.start_with?("---")
  raw_content = self.raw_content.sub("---\n", '')
  pre_amble, content = raw_content.split("---\n")
  @options = YAML.load(pre_amble)
  return content
end

#renderObject



19
20
21
22
# File 'lib/revealize/slide.rb', line 19

def render
  render_markdown
  Haml::Engine.new("%section#{section_options}\n  =rendered_markdown").render(self) 
end

#render_markdownObject



24
25
26
# File 'lib/revealize/slide.rb', line 24

def render_markdown
  @rendered_markdown = Kramdown::Document.new(content_without_preamble, :auto_ids => false).to_html
end

#section_optionsObject



36
37
38
39
# File 'lib/revealize/slide.rb', line 36

def section_options
  return '' unless @options
  return %Q{(#{@options.to_a.map {|option| "data-#{ option.first }='#{option.last}'" }.join(' ')})}
end