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

Version Path
commonmarker-1.0.4-arm64-darwin lib/commonmarker.rb
commonmarker-1.0.4-x86_64-linux lib/commonmarker.rb
commonmarker-1.0.4-x64-mingw-ucrt lib/commonmarker.rb
commonmarker-1.0.4-x86_64-darwin lib/commonmarker.rb
commonmarker-1.0.4-aarch64-linux lib/commonmarker.rb
commonmarker-1.0.4 lib/commonmarker.rb
commonmarker-1.0.3-x86_64-darwin lib/commonmarker.rb
commonmarker-1.0.3-x64-mingw-ucrt lib/commonmarker.rb
commonmarker-1.0.3-x86_64-linux lib/commonmarker.rb
commonmarker-1.0.3-aarch64-linux lib/commonmarker.rb
commonmarker-1.0.3-arm64-darwin lib/commonmarker.rb
commonmarker-1.0.3 lib/commonmarker.rb
commonmarker-1.0.2-arm64-darwin lib/commonmarker.rb
commonmarker-1.0.2-x86_64-linux lib/commonmarker.rb
commonmarker-1.0.2-aarch64-linux lib/commonmarker.rb
commonmarker-1.0.2-x86_64-darwin lib/commonmarker.rb
commonmarker-1.0.2-x64-mingw-ucrt lib/commonmarker.rb
commonmarker-1.0.2 lib/commonmarker.rb
commonmarker-1.0.1-x86_64-linux lib/commonmarker.rb
commonmarker-1.0.1-x86_64-darwin lib/commonmarker.rb