Method: YARD::Templates::Helpers::HtmlHelper#htmlify

Defined in:
lib/yard/templates/helpers/html_helper.rb

#htmlify(text, markup = options[:markup]) ⇒ String

Turns text into HTML using markup style formatting.

Parameters:

  • text (String)

    the text to format

  • markup (Symbol) (defaults to: options[:markup])

    examples are :markdown, :textile, :rdoc. To add a custom markup type, see MarkupHelper

Returns:


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/yard/templates/helpers/html_helper.rb', line 36

def htmlify(text, markup = options[:markup])
  markup_meth = "html_markup_#{markup}"
  return text unless respond_to?(markup_meth)
  return "" unless text
  return text unless markup
  html = send(markup_meth, text)
  if html.respond_to?(:encode)
    html = html.force_encoding(text.encoding) # for libs that mess with encoding
    html = html.encode(:invalid => :replace, :replace => '?')
  end
  html = resolve_links(html)
  unless [:text, :none, :pre].include?(markup)
    html = parse_codeblocks(html)
  end
  html
end