Sha256: 8d40849297f58b5d812c4d0e2d83a8ea7b3fc99941de7b395ab1058b6e36a5af

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true

require 'commonmarker'

module CommonMarker
  # Compatibility with the RedCloth API.
  # @see https://github.com/vmg/redcarpet/blob/master/lib/redcarpet/compat.rb#L1
  class CompatRenderer
    attr_accessor :text

    DEFAULT_EXTENSIONS = %i[tagfilter autolink table strikethrough].freeze
    DEFAULT_OPTIONS = %i[GITHUB_PRE_LANG].freeze

    def initialize(text, *exts, options: DEFAULT_OPTIONS)
      @text = text
      @extensions = DEFAULT_EXTENSIONS + exts
      @options = options || DEFAULT_OPTIONS
    end

    # @return [String]
    attr_reader :text

    # @return [Symbol]
    attr_reader :options

    # @return [<Symbol>]
    attr_reader :extensions

    def to_html(*_dummy)
      CommonMarker.render_html(text, options, extensions)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yard-commonmarker-0.5.0 lib/commonmarker/compat_renderer.rb