Sha256: fa16cdbea8b260f8de321ce65ead4142a871d68b675e51588c11a758f3e2cc51

Contents?: true

Size: 759 Bytes

Versions: 4

Compression:

Stored size: 759 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

    GITHUB_EXTENSIONS = %i[tagfilter autolink table strikethrough].freeze

    def initialize(text, exts = GITHUB_EXTENSIONS, options: :GITHUB_PRE_LANG)
      @text = text
      @extensions = GITHUB_EXTENSIONS | exts
      @options = options
    end

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

    private

    # @return [String]
    attr_reader :text

    # @return [Symbol]
    attr_reader :options

    # @return [<Symbol>]
    attr_reader :extensions
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
yard-commonmarker-0.4.0 lib/commonmarker/compat_renderer.rb
yard-commonmarker-0.3.0 lib/commonmarker/compat_renderer.rb
development-toolbox-0.3.0 lib/commonmarker/compat_renderer.rb
development-toolbox-0.2.0 lib/commonmarker/compat_renderer.rb