Sha256: 87d8e63c0f090a042ed7cbbb26e3c99271ce857d66da53c2d1771c0a45c30ad3

Contents?: true

Size: 521 Bytes

Versions: 3

Compression:

Stored size: 521 Bytes

Contents

# frozen_string_literal: true

module Components
  class Markdown < Phlex::Component
    class Render < Redcarpet::Render::HTML
      def header(text, level)
        case level
        when 1
          Title.new.call { text }
        else
          Heading.new.call { text }
        end
      end
    end

    MARKDOWN = Redcarpet::Markdown.new(Render.new, autolink: true, tables: true)

    def initialize(content)
      @content = content
    end

    def template
      raw MARKDOWN.render(@content)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phlex-0.2.2 docs/components/markdown.rb
phlex-0.2.1 docs/components/markdown.rb
phlex-0.2.0 docs/components/markdown.rb