Sha256: 2a3c32c5dfef9d9fbc5a9f92a7f9a9fc1c5808adf7e934a5a94a082bfeef6c91
Contents?: true
Size: 1.08 KB
Versions: 47
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true require_relative "commonmarker/extension" require "commonmarker/utils" require "commonmarker/config" require "commonmarker/renderer" require "commonmarker/version" module Commonmarker class << self # Public: Parses a CommonMark string into an HTML string. # # text - A {String} of text # options - A {Hash} of render, parse, and extension options to transform the text. # plugins - A {Hash} of additional plugins. # # Returns a {String} of converted HTML. def to_html(text, options: Commonmarker::Config::OPTIONS, plugins: Commonmarker::Config::PLUGINS) raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String) raise TypeError, "text must be UTF-8 encoded; got #{text.encoding}!" unless text.encoding.name == "UTF-8" 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) commonmark_to_html(text, options: opts, plugins: plugins) end end end
Version data entries
47 entries across 47 versions & 1 rubygems