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-5.6.5 lib/quby/markdown_parser.rb
quby-5.6.3 lib/quby/markdown_parser.rb
quby-5.6.2 lib/quby/markdown_parser.rb
quby-5.6.1 lib/quby/markdown_parser.rb
quby-5.6.0 lib/quby/markdown_parser.rb
quby-5.5.0 lib/quby/markdown_parser.rb
quby-5.4.0 lib/quby/markdown_parser.rb
quby-5.3.1 lib/quby/markdown_parser.rb
quby-5.3.0 lib/quby/markdown_parser.rb
quby-5.2.0 lib/quby/markdown_parser.rb
quby-5.1.3 lib/quby/markdown_parser.rb
quby-5.1.2 lib/quby/markdown_parser.rb
quby-5.1.1 lib/quby/markdown_parser.rb
quby-5.1.0 lib/quby/markdown_parser.rb
quby-5.0.5 lib/quby/markdown_parser.rb
quby-5.0.4 lib/quby/markdown_parser.rb
quby-5.0.3 lib/quby/markdown_parser.rb
quby-5.0.2 lib/quby/markdown_parser.rb
quby-5.0.1 lib/quby/markdown_parser.rb
quby-5.0.0 lib/quby/markdown_parser.rb