Method: Commonmarker::Node#to_commonmark

Defined in:
lib/commonmarker/node.rb

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

Public: Convert the node to a CommonMark string.

options - A Symbol or of Symbols indicating the render options plugins - A Hash of additional plugins.

Returns a String.

Raises:

  • (TypeError)


56
57
58
59
60
61
62
63
# File 'lib/commonmarker/node.rb', line 56

def to_commonmark(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_commonmark(render: opts[:render], parse: opts[:parse], extension: opts[:extension], plugins: plugins).force_encoding("utf-8")
end