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:



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/yard/templates/helpers/html_helper.rb', line 57

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).dup
  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, :ruby].include?(markup)
    html = parse_codeblocks(html)
  end
  html
end