Class: Thredded::HtmlPipeline::KramdownFilter

Inherits:
HTML::Pipeline::TextFilter
  • Object
show all
Defined in:
lib/thredded/html_pipeline/kramdown_filter.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, context = nil, result = nil) ⇒ KramdownFilter

Returns a new instance of KramdownFilter.



21
22
23
24
25
26
27
28
# File 'lib/thredded/html_pipeline/kramdown_filter.rb', line 21

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

Class Attribute Details

.optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/thredded/html_pipeline/kramdown_filter.rb', line 8

def options
  @options
end

Instance Method Details

#callObject

Convert Markdown to HTML using the best available implementation and convert into a DocumentFragment.



32
33
34
35
36
# File 'lib/thredded/html_pipeline/kramdown_filter.rb', line 32

def call
  result = Kramdown::Document.new(@text, self.class.options.deep_merge(context[:kramdown_options] || {})).to_html
  result.rstrip!
  result
end