Class: Texter::MarkdownFormatter

Inherits:
Formatter show all
Defined in:
app/lib/texter/markdown_formatter.rb

Instance Attribute Summary

Attributes inherited from Formatter

#body, #options

Instance Method Summary collapse

Methods inherited from Formatter

#initialize

Constructor Details

This class inherits a constructor from Texter::Formatter

Instance Method Details

#blockObject



24
25
26
27
28
29
# File 'app/lib/texter/markdown_formatter.rb', line 24

def block
  return nil if body.blank?

  markdown = ::RDiscount.new(body, *options[:extensions])
  markdown.to_html
end

#inlineObject

extracts html from the first paragraph or header



20
21
22
# File 'app/lib/texter/markdown_formatter.rb', line 20

def inline
  block.match(%r{<[hp]\d?>(.*?)</[hp]\d?>}).try(:[], 1)
end