Sha256: 9c0547f885fa3430224225e5c71e735d1ef670bd65dcde2db275746dbe297640

Contents?: true

Size: 714 Bytes

Versions: 9

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true

require 'redcarpet'

require 'quby/compiler/services/text_transformation'

module Quby::Compiler
  class MarkdownParser
    include Quby::Compiler::Services::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

9 entries across 9 versions & 1 rubygems

Version Path
quby-compiler-0.5.9 lib/quby/compiler/markdown_parser.rb
quby-compiler-0.5.8 lib/quby/compiler/markdown_parser.rb
quby-compiler-0.5.7 lib/quby/compiler/markdown_parser.rb
quby-compiler-0.5.6 lib/quby/compiler/markdown_parser.rb
quby-compiler-0.5.5 lib/quby/compiler/markdown_parser.rb
quby-compiler-0.5.4 lib/quby/compiler/markdown_parser.rb
quby-compiler-0.5.3 lib/quby/compiler/markdown_parser.rb
quby-compiler-0.5.2 lib/quby/compiler/markdown_parser.rb
quby-compiler-0.5.1 lib/quby/compiler/markdown_parser.rb