Method: Commonmarker::Node#to_html

Defined in:
lib/commonmarker/node.rb

#to_html(options: Commonmarker::Config::OPTIONS, plugins: Commonmarker::Config::PLUGINS) ⇒ Object

Public: Converts a node to an HTML string.

options - A Hash of render, parse, and extension options to transform the text. plugins - A Hash of additional plugins.

Returns a String of HTML.

Raises:

  • (TypeError)


41
42
43
44
45
46
47
48
# File 'lib/commonmarker/node.rb', line 41

def to_html(options: Commonmarker::Config::OPTIONS, plugins: Commonmarker::Config::PLUGINS)
  raise TypeError, "options must be a Hash; got a #{options.class}!" unless options.is_a?(Hash)

  opts = Config.process_options(options)
  plugins = Config.process_plugins(plugins)

  node_to_html(render: opts[:render], parse: opts[:parse], extension: opts[:extension], plugins: plugins).force_encoding("utf-8")
end