Sha256: 1f0222dfbfc4d2549bbbdf179ba75d5dc34c7e42e057f9434f611bace593079d

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require "redcarpet"
require "rouge"
require "rouge/plugins/redcarpet"

module Milestoner
  module Renderers
    # Renders Markdown as HTML.
    class Markdown
      CLIENT = Redcarpet::Markdown.new Class.new(Redcarpet::Render::HTML)
                                            .include(Rouge::Plugins::Redcarpet)
                                            .set_temporary_name("redcarpet_html_rouge")
                                            .new,
                                       disable_indented_code_blocks: true,
                                       fenced_code_blocks: true,
                                       footnotes: true,
                                       highlight: true,
                                       superscript: true,
                                       tables: true

      def initialize client: CLIENT
        @client = client
      end

      def call(content) = client.render content

      private

      attr_reader :client
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
milestoner-18.8.0 lib/milestoner/renderers/markdown.rb
milestoner-18.7.0 lib/milestoner/renderers/markdown.rb
milestoner-18.6.0 lib/milestoner/renderers/markdown.rb
milestoner-18.5.0 lib/milestoner/renderers/markdown.rb