Class: Thredded::HtmlPipeline::KramdownFilter
- Inherits:
-
HTML::Pipeline::TextFilter
- Object
- HTML::Pipeline::TextFilter
- Thredded::HtmlPipeline::KramdownFilter
- Defined in:
- lib/thredded/html_pipeline/kramdown_filter.rb
Class Attribute Summary collapse
-
.options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#call ⇒ Object
Convert Markdown to HTML using the best available implementation and convert into a DocumentFragment.
-
#initialize(text, context = nil, result = nil) ⇒ KramdownFilter
constructor
A new instance of KramdownFilter.
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
.options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/thredded/html_pipeline/kramdown_filter.rb', line 8 def @options end |
Instance Method Details
#call ⇒ Object
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..deep_merge(context[:kramdown_options] || {})).to_html result.rstrip! result end |