Class: PagesCore::HtmlFormatter

Inherits:
Object
  • Object
show all
Defined in:
app/formatters/pages_core/html_formatter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, options = {}) ⇒ HtmlFormatter

Returns a new instance of HtmlFormatter.



11
12
13
14
# File 'app/formatters/pages_core/html_formatter.rb', line 11

def initialize(string, options = {})
  @string = string
  @options = options
end

Class Method Details

.to_html(string, options = {}) ⇒ Object



6
7
8
# File 'app/formatters/pages_core/html_formatter.rb', line 6

def to_html(string, options = {})
  new(string, options).to_html
end

Instance Method Details

#to_htmlObject



16
17
18
19
20
# File 'app/formatters/pages_core/html_formatter.rb', line 16

def to_html
  string = shorten(parse_images(parse_files(parse_attachments(@string))))
  string += " #{@options[:append]}" if @options[:append]
  fix_markup(RedCloth.new(string).to_html).html_safe
end