Sha256: 8da2f2195c0c3ce9f06e8615e38e95ffdab44f87a6b2c0ef52583254d220f583

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module Mado
  class Markdown
    class HTML < Redcarpet::Render::HTML
      include Rouge::Plugins::Redcarpet
    end

    class << self
      def convert_markdown(path)
        renderer_options = {
          filter_html: true,
          with_toc_data: true
        }
        convert_options = {
          autolink: true,
          fenced_code_blocks: true,
          lax_spacing: true,
          no_intra_emphasis: true,
          strikethrough: true,
          superscript: true,
          tables: true
        }
        pipeline_context = {
          asset_root: ""
        }
        pipeline = ::HTML::Pipeline.new [
          ::HTML::Pipeline::EmojiFilter,
          TaskList::Filter
        ]

        renderer = HTML.new(renderer_options)
        html = Redcarpet::Markdown.new(renderer, convert_options).render(open(path).read)
        pipeline.call(html, pipeline_context)[:output].to_s
      end

      def emoji_path(file_path)
        File.join(Emoji.images_path, "emoji", file_path)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mado-0.2.1 lib/mado/markdown.rb
mado-0.2.0 lib/mado/markdown.rb