Sha256: 288612a055e725be9778aae52df456e92b93d16961af7da8c26b0fa924ec48bd

Contents?: true

Size: 682 Bytes

Versions: 33

Compression:

Stored size: 682 Bytes

Contents

# frozen_string_literal: true

require 'quby/answers/services/text_transformation'
require 'redcarpet'

module Quby
  class MarkdownParser
    include Quby::TextTransformation

    EXTENTIONS = {
      no_intra_emphasis: true
    }.freeze

    def initialize(source)
      @source = source || ""
    end

    def to_html
      rc_html = parser.render(@source).strip
      transform_special_text(rc_html)
    end

    def html_safe
      to_html.html_safe
    end

    private

    def parser
      @@parser ||= Redcarpet::Markdown.new(HTMLWithPants.new, EXTENTIONS)
    end
  end

  class HTMLWithPants < Redcarpet::Render::HTML
    include Redcarpet::Render::SmartyPants
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
quby-4.0.4 lib/quby/markdown_parser.rb
quby-5.0.0.pre4 lib/quby/markdown_parser.rb
quby-5.0.0.pre3 lib/quby/markdown_parser.rb
quby-5.0.0.pre2 lib/quby/markdown_parser.rb
quby-5.0.0.pre1 lib/quby/markdown_parser.rb
quby-4.0.3 lib/quby/markdown_parser.rb
quby-4.0.2 lib/quby/markdown_parser.rb
quby-4.0.1 lib/quby/markdown_parser.rb
quby-4.0.0 lib/quby/markdown_parser.rb
quby-3.2.2 lib/quby/markdown_parser.rb
quby-3.2.1 lib/quby/markdown_parser.rb
quby-3.2.0 lib/quby/markdown_parser.rb
quby-3.2.0.pre.pre1 lib/quby/markdown_parser.rb