Class: Sendmark::Markdown

Inherits:
Object
  • Object
show all
Defined in:
lib/sendmark/markdown.rb

Instance Method Summary collapse

Constructor Details

#initialize(css_parser) ⇒ Markdown

Returns a new instance of Markdown.



3
4
5
6
7
# File 'lib/sendmark/markdown.rb', line 3

def initialize(css_parser)
  @css_parser = css_parser
  render = Sendmark::Render.new(css_parser: @css_parser)
  @markdown = Redcarpet::Markdown.new(render)
end

Instance Method Details

#body_end_tagObject



23
24
25
# File 'lib/sendmark/markdown.rb', line 23

def body_end_tag
  "</body>"
end

#body_start_tagObject



13
14
15
16
17
18
19
20
21
# File 'lib/sendmark/markdown.rb', line 13

def body_start_tag
  style = @css_parser.body

  unless style.nil?
    "<body style=\"#{style}\">"
  else
    "<body>"
  end
end

#render(text) ⇒ Object



9
10
11
# File 'lib/sendmark/markdown.rb', line 9

def render(text)
  "#{body_start_tag}#{@markdown.render(text)}#{body_end_tag}"
end