Class: HTML::Pipeline::KramdownFilter

Inherits:
TextFilter
  • Object
show all
Defined in:
lib/mbrao/rendering_engines/html_pipeline/kramdown_filter.rb

Overview

A filter to compile Markdown contents.

Instance Method Summary collapse

Constructor Details

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

Creates a new filter.

Parameters:

  • text (String)

    The string to convert.

  • context (Hash) (defaults to: nil)

    The context of the conversion.

  • result (Hash) (defaults to: nil)

    A result hash.



18
19
20
21
# File 'lib/mbrao/rendering_engines/html_pipeline/kramdown_filter.rb', line 18

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

Instance Method Details

#callDocumentFragment

Converts Markdown to HTML using Kramdown and converts into a DocumentFragment.

Returns:

  • (DocumentFragment)

    The converted fragment.



26
27
28
# File 'lib/mbrao/rendering_engines/html_pipeline/kramdown_filter.rb', line 26

def call
  Kramdown::Document.new(@text, @context).to_html
end