Sha256: ac55e592bca8eebf1e4ef0b8c131d9d9d22f621d2a5a7f4d4fbb414068944d3f

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require "redcarpet"
require "refinements/module"
require "rouge"
require "rouge/plugins/redcarpet"

module Milestoner
  module Renderers
    # Renders Markdown as HTML.
    class Markdown
      using Refinements::Module

      CLIENT = Redcarpet::Markdown.new Class.new(Redcarpet::Render::HTML)
                                            .include(Rouge::Plugins::Redcarpet)
                                            .pseudonym("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.12.0 lib/milestoner/renderers/markdown.rb
milestoner-18.11.0 lib/milestoner/renderers/markdown.rb
milestoner-18.10.0 lib/milestoner/renderers/markdown.rb
milestoner-18.9.0 lib/milestoner/renderers/markdown.rb