Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/mill/html_helpers.rb

Direct Known Subclasses

HTMLHelpers::PreText

Constant Summary collapse

Converters =
{
  nil => RubyPants,
  smart_quotes: RubyPants,
  markdown: Kramdown::Document,
  textile: RedCloth,
  pre: PreText,
}

Instance Method Summary collapse

Instance Method Details

#to_html(options = {}) ⇒ Object



111
112
113
114
115
116
117
118
# File 'lib/mill/html_helpers.rb', line 111

def to_html(options={})
  converter = Converters[options[:mode]] or raise "Unknown to_html mode: #{options[:mode].inspect}"
  html = Nokogiri::HTML::DocumentFragment.parse(converter.new(self).to_html)
  if !options[:multiline] && (p_elem = html.at_xpath('p'))
    html = p_elem.children.to_html
  end
  html.to_html
end