Method: YARD::Templates::Helpers::HtmlHelper#html_syntax_highlight

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

#html_syntax_highlight(source, type = nil) ⇒ String

Note:

To support a specific language type, implement the method html_syntax_highlight_TYPE in this class.

Syntax highlights source in language type.

Parameters:

  • source (String)

    the source code to highlight

  • type (Symbol, String) (defaults to: nil)

    the language type (:ruby, :plain, etc). Use :plain for no syntax highlighting.

Returns:

  • (String)

    the highlighted source

[View source]

154
155
156
157
158
159
160
161
162
# File 'lib/yard/templates/helpers/html_helper.rb', line 154

def html_syntax_highlight(source, type = nil)
  return "" unless source
  return h(source) if options[:no_highlight]

  new_type, source = parse_lang_for_codeblock(source)
  type ||= new_type || :ruby
  meth = "html_syntax_highlight_#{type}"
  respond_to?(meth) ? send(meth, source) : h(source)
end