Module: Commonmarker

Defined in:
lib/commonmarker.rb,
lib/commonmarker/config.rb,
lib/commonmarker/version.rb,
lib/commonmarker/renderer.rb

Defined Under Namespace

Modules: Config Classes: Renderer

Constant Summary collapse

VERSION =
"1.0.0.pre3"

Class Method Summary collapse

Class Method Details

.to_html(text, options: Commonmarker::Config::OPTS) ⇒ Object

Public: Parses a CommonMark string into an HTML string.

text - A String of text option - A Hash of render, parse, and extension options to transform the text.

Returns a String of converted HTML.

Raises:

  • (TypeError)


22
23
24
25
26
27
28
# File 'lib/commonmarker.rb', line 22

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

  opts = Config.process_options(options)
  commonmark_to_html(text.encode("UTF-8"), opts)
end