Sha256: b302c78e5339f3e8b97ac0953f887fbaec88e0522e696f5d8c98143db3540e0b

Contents?: true

Size: 948 Bytes

Versions: 8

Compression:

Stored size: 948 Bytes

Contents

# frozen_string_literal: true
require 'kramdown'
module Thredded
  module HtmlPipeline
    class KramdownFilter < ::HTML::Pipeline::TextFilter
      class << self
        attr_accessor :options
      end

      # See http://kramdown.gettalong.org/options.html
      self.options = {
        input: 'GFM',
        gfm_quirks: 'paragraph_end',
        # Smart quotes conflict with @"at mentions". Disable smart quotes.
        smart_quotes: %w(apos apos quot quot),
        remove_block_html_tags: false,
        syntax_highlighter: nil
      }

      def initialize(text, context = nil, result = nil)
        super text, context, result
        @text.delete! "\r"
      end

      # Convert Markdown to HTML using the best available implementation
      # and convert into a DocumentFragment.
      def call
        result = Kramdown::Document.new(@text, self.class.options).to_html
        result.rstrip!
        result
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
thredded-0.10.1 lib/thredded/html_pipeline/kramdown_filter.rb
thredded-0.10.0 lib/thredded/html_pipeline/kramdown_filter.rb
thredded-0.9.4 lib/thredded/html_pipeline/kramdown_filter.rb
thredded-0.9.3 lib/thredded/html_pipeline/kramdown_filter.rb
thredded-0.9.2 lib/thredded/html_pipeline/kramdown_filter.rb
thredded-0.9.1 lib/thredded/html_pipeline/kramdown_filter.rb
thredded-0.8.4 lib/thredded/html_pipeline/kramdown_filter.rb
thredded-0.8.2 lib/thredded/html_pipeline/kramdown_filter.rb